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
A great way to apply two way binding is to use directive components. Here is my solution. It allows use of ng-repeat and expandable data binding.
View Plunker
HTML
Data: {{data}}
Controller
app.controller('MainCtrl', function($scope) {
$scope.data = [];
$scope.data[0] = 'Marco';
$scope.data[1] = 'Billy';
});
Directive
app.directive("mydirective", function(){
return {
restrict: "EA",
scope: {name: '='},
template: "Your name is : {{name}}"+
"Change your name : "
};
});
In the case of the counter, it can be done using the same method.