Hello everyone...Can anybody explain me what I'm doing wrong here...
Let's say that I'm having something like this:
var app = angular.module("app", []);
app.controller("controller", function ($scope) {
$scope.myClass = "class1";
});
app.directive("myDirective", function () {
return {
restrict: "AEC",
replace: true,
template: "<div ng-class='myClass'></div>",
link: function ($scope, elem, attrs) {
elem.bind("click", function () {
$scope.myClass = "class2";
});
}
}
});
As far as I can understand when I click on the proper <div> it should
change the value of parent scope variable "myClass" to "class2" value. But
on the UI this change is not reflecting. Should I create maybe isolated
scope or something like that.
Is it possible to change values of the parent scope from the directive ?
Please disregard all potential miss typos in the code...
--
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.