Reputation: 1237
I am experiencing something strange when running grunt-angular. For some reasons it is seeing files however ignoring them when running the command `grunt release -v'. the result is:
Running "angular-builder:app" (angular-builder) task
Verifying property angular-builder.app exists in config...OK
Files: app/components/home/homeController.js, app/core/app.js -> build/admin_tools.js
Options: mainModule="AdminTools"
Reading app/components/home/homeController.js...OK
Ignored file: app/components/home/homeController.js
Generating the release build...
Not optimizing anchorScrollOffsetExample because it shares some/all of its files with other modules.
Including module ngRoute.
Scanning ngRoute for non-angular script dependencies...
Validating app/core/angular-route.js...OK
Including module AdminTools.
Scanning AdminTools for non-angular script dependencies...
Validating app/core/app.js...OK
Writing build/admin_tools.js...OK
Done, without errors.
As you can see there is a js file called homController.js
which it sees, but then ignores it and I can't figure out why. The contents of that file is.
app.controller('homeController', ['$scope', '$log', function ($scope, $log){
doThis = function(){
alert('Hello There');
}
}]);
Pretty simple stuff. The app.js looks like this:
var app = angular.module('AdminTools', ['ngRoute']);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'app/templates/login.html',
controller: 'homeController'
})
.otherwise({ redirectTo: '/' });
}]);
-- EDIT Adding Grunt File --
module.exports = function (grunt){
grunt.initConfig ({
'angular-builder': {
options: {
mainModule: 'AdminAdmin'
},
app: {
src: 'app/**/*.js',
dest: 'build/admin_tools.js'
}
}
});
grunt.loadNpmTasks ('grunt-angular-builder');
grunt.registerTask ('default', ['angular-builder']);
grunt.registerTask ('release', ['angular-builder']);
grunt.registerTask ('debug', ['angular-builder::debug']);
};
Not sure what I'm missing.
Upvotes: 1
Views: 217
Reputation: 1237
I was able to figure out the problem. It had to do with the way I was modularizing the app.
The controller needed to be:
angular.module('home.controller', [])
.controller('homeController', ['$scope', '$log', function ($scope, $log){
doThis = function(){
alert('Hello There');
}
}]);
with the app.js registering the dependency like so.
angular.module('AdminTools', [
'ngRoute',
'home.controller']);
angular.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'app/templates/login.html',
controller: 'homeController'
})
.otherwise({ redirectTo: '/' });
}]);
Upvotes: 1