Hey!
This does not work:
<body ng-controller="MainCtrl">
<div test ng-click="changeVar(variable.value)">{{ variable.value
}}</div>
</body>
app.directive('test', [function(){
return {
link: function(scope, elem, attrs) {
scope.variable = {
value : "bla"
};
scope.changeVar = function(value) {
value = "hhuhu"
};
}
}
}]);
But this does:
<body ng-controller="MainCtrl">
<div test ng-click="changeObj(variable)">{{ variable.value }}</div>
</body>
app.directive('test', [function(){
return {
link: function(scope, elem, attrs) {
scope.variable = {
value : "bla"
};
scope.changeObj = function(obj) {
obj.value = "hhuhu"
};
}
}
}]);
Why do I have to pass the parent Object to the function to overwrite the
value, and cannot pass the value directly to overwrite it? Am I missing
something?
--
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 https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.