AngularJS Playground
HTML
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<div ng-controller="MyCtrl">
<test-directive items="items"></test-directive>
</div>
JavaScript
var myApp = angular.module('myApp', []);
myApp.controller('MyCtrl', function($scope) {
$scope.items = [
{name: 'item1': value: true},
{name: 'item2': value: false},
{name: 'item3': value: true}
];
$scope.$watch('items', function(newVal, oldVal) {
console.log(oldVal, newVal);
}, true);
});
myApp.directive('testDirective', function() {
return {
restrict: 'E',
replace: true,
scope: {
items: '='
},
template: "<div ng-repeat='item in items'><label><input type='checkbox' ng-model='item.value'/>{{item.name + 'a'}}</label></div>"
};
});