Using 'this' Instead Of $scope Failed In Angularjs
I used megaboiletplate.com for scalfoding my project. I downloaded a starter pack but I'm facing some issue. I've put the starter code to a repo in this file, line 16 is not trigg
Solution 1:
make sure that your code is using the 'controller as' syntax. You can use this
in the controller but you must redefine the controller in the HTML. like:
<bodyng-controller="mycontroller as ctrl">
then you can use the controller functions like
<formng-submit="ctrl.login()">
https://docs.angularjs.org/api/ng/directive/ngController
you may have to edit your routing if your controller is assigned there.
.when('/login', {
templateUrl: 'partials/login.html',
controller: 'LoginCtrl',
resolve: { skipIfAuthenticated: skipIfAuthenticated }
})
would be changed to:
.when('/login', {
templateUrl: 'partials/login.html',
controller: 'LoginCtrl',
controllerAs: 'ctrl',
resolve: { skipIfAuthenticated: skipIfAuthenticated }
})
in your case this should be found in the app.js of the boilerplate
Post a Comment for "Using 'this' Instead Of $scope Failed In Angularjs"