我收到以下错误:
Error: [$injector:unpr] Unknown provider: nProvider <- n
Run Code Online (Sandbox Code Playgroud)
我知道这是由缩小过程引起的,我理解为什么.但是,是否有一种简单的方法可以确定哪个文件实际导致了问题?
我正在尝试使用samaxes minify maven插件在我的angularjs应用程序中缩小javascripts和css文件.我能够将所有js和css缩小并使用maven构建war文件,但在尝试打开应用程序URL时,我得到了Error: [$injector:unpr] Unknown provider: aProvider <- a我的应用程序无效.
下面我提供我的pom插件配置
<plugin>
<groupId>com.samaxes.maven</groupId>
<artifactId>minify-maven-plugin</artifactId>
<version>1.7.4</version>
<executions>
<execution>
<id>min-js</id>
<phase>prepare-package</phase>
<goals>
<goal>minify</goal>
</goals>
</execution>
</executions>
<configuration>
<charset>UTF-8</charset>
<skipMerge>true</skipMerge>
<cssSourceDir>myapp/styles</cssSourceDir>
<jsSourceDir>myapp/javascript</jsSourceDir>
<jsEngine>CLOSURE</jsEngine>
<closureLanguage>ECMASCRIPT5</closureLanguage>
<closureAngularPass>true</closureAngularPass>
<nosuffix>true</nosuffix>
<webappTargetDir>${project.build.directory}/minify</webappTargetDir>
<cssSourceIncludes>
<cssSourceInclude>**/*.css</cssSourceInclude>
</cssSourceIncludes>
<cssSourceExcludes>
<cssSourceExclude>**/*.min.css</cssSourceExclude>
</cssSourceExcludes>
<jsSourceIncludes>
<jsSourceInclude>**/*.js</jsSourceInclude>
</jsSourceIncludes>
<jsSourceExcludes>
<jsSourceExclude>**/*.min.js</jsSourceExclude>
</jsSourceExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<webResources>
<resource>
<directory>${project.build.directory}/minify</directory>
</resource>
</webResources>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
目录结构

我的控制器结构
'use strict';
angular.module('myApp').controller('MyController', function($scope, $filter, $location, $interval, ngTableParams, $modal, $transition, myService, $timeout) {
...
}); …Run Code Online (Sandbox Code Playgroud) 我在带有资产的Ruby on Rails 3.2.8项目中使用AngularJS.
当我加载在我的开发机器上使用AngularJS的表单时,我没有问题.但是,当我在生产服务器上加载相同的表单时,我在Javascript控制台中收到此错误:
Error: Unknown provider: aProvider <- a
Run Code Online (Sandbox Code Playgroud)
我已经将它追溯到我的coffeescript文件,我在其中设置AngularJS以便在表单中使用:
$ (event) ->
$("#timesheet_description").autocomplete({source: '/autocomplete/work_descs'})
# Create AngularJS module
app = angular.module 'timesheetApp', []
# Create a AngularJS controller
app.controller "TimesheetCtrl", ($scope) ->
$scope.costed_amount = 0
# Bind my module to the global variables so I can use it.
angular.bootstrap document, ["timesheetApp"]
Run Code Online (Sandbox Code Playgroud)
如果我评论所有这一切,页面将加载没有错误和没有AngularJS能力.
问题是由于Rails资产编译和缩小?有没有办法解决这个问题,仍然使用coffeescript和Rails资产?