Skip to content Skip to sidebar Skip to footer

Angular Module Config Not Called

I'm trying to get my head around AngularJS and ran into a problem. var myApp = angular.module('myApp', ['myApp.services']); myApp.config(['$routeProvider', '$locationProvider', fu

Solution 1:

It seems that the method I used for defining the service was overriding my myApp module.

This is the overriding line

angular.module('myApp', function($provide) ...

This code simply redefines the myApp module and adds a function to configure that one.


I refactored service.js to this simplified version and it started to work.

var myApp = angular.module('myApp');

myApp.factory('securityService', function () {
    returnSomeFancyServiceObject();
});

Solution 2:

I was missing ng-app="myApp" inside my html tag - and I realized this while reading your question :-)

Solution 3:

I usually see routing applied by chaining them together:

$routeProvider
    .when('/dashboard', {templateUrl:'partial/dashboard', controller: DashboardController})
    .when('/menu', {templateUrl:'partial/other', controller: OtherController})
    .otherwise({redirectTo:'/dashboard'});

Can't see why yours would not work, but might be worth a go.

Post a Comment for "Angular Module Config Not Called"