the only way I can get it to work is using $watch and creating a function
on my controller's scope
that returns the state of the model, and then set the model's value to the
scope's value.
But this doesn't feel too clean. Is there no way to simply bind the model
to the controller's scope?
The above illustrated, in my controller:
$scope.isLoggedIn = function() {
return LoginModel.getLoggedIn()
};
$scope.$watch($scope.isLoggedIn, onLoggedInChange);
function onLoggedInChange() {
$scope.dataObject.loggedIn = LoginModel.getLoggedIn()
console.log('watch login: ',$scope.dataObject.loggedIn,
LoginModel.getLoggedIn());
}
LoginModel:
myAppModule.service("LoginModel", [function() {
var loggedIn = 'no';
this.setLoggedIn = function(state) {
loggedIn = state;
};
this.getLoggedIn = function(state) {
return loggedIn;
};
}]);
Thanks :)
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.