Reputation: 1229
I am trying to perform a simple login action in a LoginController
, and trying to store the result in a loggedIn
property of the controller. In tryLogin()
of the controller,when I make ajax call and set the property of the controller using App.LoginController.loggedIn=true
that is not reflected in the controller.
please check this JSBin
I am suspecting something wrong with the my understanding of the scoping, but not able to resolve this
Upvotes: 0
Views: 114
Reputation: 3971
You need to set the loggedIn
property on the controller instance, not the controller class definition. Which means you need to use self.set('loggedIn', true)
instead of App.LoginController.loggedIn = true
.
Another thing to remember, always use object.set('prop', 'val')
instead of object.prop = 'val'
Here's the updated JSBin
Upvotes: 1