If I have an AngularJS directive without a template and I want it to set a property on the current scope, what is the best way to do it?
For example, a directive tha
Change template to:
Click Count: {{ counter.val }}
and directive to:
.directive('twoway',
function() {
return {
scope: {
localValue: '=?bind'
},
link: function(scope, elem, attrs) {
scope.localValue = {
val: 0
};
elem.on('click', function() {
scope.localValue.val = scope.localValue.val + 1;
scope.$apply();
});
}
};
}
);