How to modify a scope's value within a directive
Within a directive, I'd like to modify the expression's value when a
button is clicked. The below code is only modifying the value locally
within my directive. I'd like to change the value outside of this
directive as well. How can I accomplish that?
scope: false,
link: function (scope, el, attrs) {
//toggle the state when clicked
el.bind('click', function () {
scope[attrs.ngModel] = !scope[attrs.ngModel];
});
Plunker: http://plnkr.co/edit/xqYBnz5BHLP844kXJXKs?p=preview
No comments:
Post a Comment