Uncaught Error: [$injector:modulerr] in AngularJS -


i have sample on angular js as:

angular.module('wm-admin', []).     config(function($routeprovider) {         $routeprovider.             when('/users', {controller:userscontroller, templateurl:'/public/html/crm/users/list.html'}).             otherwise({redirectto:'/users'});     });  // controllers // function userscontroller($scope) {  } 

it gives me error:

uncaught error: [$injector:modulerr] 

so, wrong?

html:

<body ng-app="wm-admin"> </body> 

i tried code:

angular js:

(function (angular) {     'use strict';      angular.module('wm-admin', [])         .config(function($routeprovider) {         $routeprovider.             when('/users', {controller:userscontroller, templateurl:'/public/html/crm/users/list.html'}).             otherwise({redirectto:'/users'});     })      // controllers //     .controller('userscontroller', ['$scope', '$http', function ($scope, $http) {      }])  })(window.angular); 

look please code upper

you haven't injected controller app. add line:

angular.module('wm-admin').controller('userscontroller', userscontroller); 

edit

in updated question have code:

(function (angular) {     'use strict';      angular.module('wm-admin', [])         .config(function($routeprovider) {         $routeprovider.             when('/users', {controller:userscontroller, templateurl:'/public/html/crm/users/list.html'}).             otherwise({redirectto:'/users'});     })      // controllers //     .controller('userscontroller', ['$scope', '$http', function ($scope, $http) {      }])  })(window.angular); 

but userscontroller no longer function within scope of {controller: userscontroller} line. change controller: 'userscontroller' (string, not reference function):

(function (angular) {     'use strict';      angular.module('wm-admin', [])         .config(function($routeprovider) {         $routeprovider.             when('/users', {controller: 'userscontroller', templateurl:'/public/html/crm/users/list.html'}).             otherwise({redirectto:'/users'});     })      // controllers //     .controller('userscontroller', ['$scope', '$http', function ($scope, $http) {      }])  })(window.angular); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -