L
L
leo_fr2015-11-05 13:04:08
Angular
leo_fr, 2015-11-05 13:04:08

Error: [ng:areq] Argument controller is not a function, got undefined?

Good afternoon, angular throws an error Error: [ng:areq] Argument 'usersCtrl' is not a function, got undefined .
I can’t understand why he swears, for the test I wrote the simplest interaction and everything seems to work, but no. The project also has controllers and they work fine, the problem is creating new screenshots of code pieces.:

<script src="scripts/controllers/pageUserCtrl.js" type="text/javascript"></script>

controller
d0c18010a069475185c94ecfadce9525.png
app.js
b82b5f6cf2ab4e2289a16a3af9fbc379.png
user.html 43dde21a3bea4864a6a6124ff2a7ac8f.png
error91315d3f04f44e72ba8e453a40f83386.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Radiks Alijevs, 2015-11-05
@dedalik

//app.js
angular.module('prApp', [])
    .controller('usersCtrl',['$scope' , function ($scope) {
        $scope.message = 'Page test';
    }
]);
//users2Ctrl.js
angular.module('prApp')
    .controller('users2Ctrl', UsersCtrl)
    
UsersCtrl.$inject = ['$scope'];

function UsersCtrl ($scope) {
  $scope.message = 'User2Ctrl';
}

or
//app.js
angular.module('prApp', [
  '..',
  'userCtrl'
]);

//userCtrl.js
angular.module('userCtrl', [])
.controller('userCtrl',...

Angular style guide

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question