Javascript Angular:将Angular js文件压缩成单个js文件后出错
我正在使用gulp concat将所有angular js文件合并为一个文件,但在运行gulp任务后,我在运行应用程序的chrome控制台中遇到以下错误:Javascript Angular:将Angular js文件压缩成单个js文件后出错,javascript,angularjs,gulp,gulp-concat,Javascript,Angularjs,Gulp,Gulp Concat,我正在使用gulp concat将所有angular js文件合并为一个文件,但在运行gulp任务后,我在运行应用程序的chrome控制台中遇到以下错误: angular.js:13708Error: [ng:areq] http://errors.angularjs.org/1.5.7/ng/areq?p0=userboxController&p1=not%20a%20function%2C%20got%20undefined 我的吞咽任务: gulp.task('scripts',
angular.js:13708Error: [ng:areq] http://errors.angularjs.org/1.5.7/ng/areq?p0=userboxController&p1=not%20a%20function%2C%20got%20undefined
我的吞咽任务:
gulp.task('scripts', function () {
return gulp.src(['js/app/*.js', 'components/*/*/*.js'])
.pipe(concat('appscript.js'))
.pipe(minify())
.pipe(gulp.dest('./dist/js/'));
});
gulp concat将专用的angular js文件合并到appscript.js中,如:
你怎么了 这不是与合并相关的问题 您每次都在使用
angular.module('app', [])
您只需在一个地方初始化模块,每次都将使用相同的模块,并带有~[]括号
请找到那个笨蛋
这不是与合并相关的问题 您每次都在使用
angular.module('app', [])
您只需在一个地方初始化模块,每次都将使用相同的模块,并带有~[]括号
请找到那个笨蛋
我认为合并js顺序或角度注入可能有问题!为什么不直接执行var-app=angular.module'app',[];和app.controllerpaymentCtrl。。。相反?@Arg0n没问题,我手动编辑了appscript.js以使用var app=angular.module'app',[];但我的控制器和服务,。。在专用的.js文件中,必须添加var app=angular.module'app',[];对于所有人来说,如何解决这种冗余?如果我删除var app=angular.module'app',[];从除app.JS之外的所有JS文件中,为避免冗余,我在添加var app=angular.module'app',[]时出错;在每一个js文件中,我的问题都会得到解决。我认为合并js顺序或角度注入可能有问题!为什么不直接执行var-app=angular.module'app',[];和app.controllerpaymentCtrl。。。相反?@Arg0n没问题,我手动编辑了appscript.js以使用var app=angular.module'app',[];但我的控制器和服务,。。在专用的.js文件中,必须添加var app=angular.module'app',[];对于所有人来说,如何解决这种冗余?如果我删除var app=angular.module'app',[];从除app.JS之外的所有JS文件中,为避免冗余,我在添加var app=angular.module'app',[]时出错;在每个js文件中,我的问题都会得到解决。是的,它起作用了:,但我在从var myApp=angular.module'app',[]中删除[]时出错。我在var myApp=angular.module'app'中有[]。我不知道为什么!是的,它起作用了:,但是我从var myApp=angular.module'app',[]中删除[]时出错。我在var myApp=angular.module'app'中有[]。我不知道为什么!
var myApp = angular.module('app');
myApp.controller("paymentCtrl", ['$scope', '$http', function($scope, $http) {
$http.get('data/payments.json').then(function(payments) {
$scope.payments = payments.data;
});
$scope.saveEntity = function() {
console.info("goog");
}
}]);
myApp.controller("userboxController", ['$scope', '$http', function($scope, $http, usersService) {
$scope.user = 'abc';
}]);
myApp.controller("usersController", ['$scope', '$http', 'usersService', function($scope, $http, usersService) {
usersService.getAll().then(function(users) {
$scope.users = users.data;
});
}]);
myApp.directive('usersGrid', function() {
return {
templateUrl: 'components/users/template/grid.html'
}
});