I'm new to AngularJS. I've built a directive that uses an Isolate Scope (=) on an array called "todos". I then filter the todos array, and call it filteredArray. My "todos" element is updated using bidirectional binding, but I do not know what must be done to bind the update of todos to filteredArray.
I've set up a fiddle for my experimenting here: http://jsfiddle.net/apkk3rjc/ You can even see I've tried to set up a simple $watch() on line 50 of my JS but it doesn't seem to trigger beyond the first load.
To be clear: I don't need two-way binding back to my controller, but I do need the filteredTodos to update automatically when a change to todos is made.
Here is my directive:
todoApp.directive('todoList', ['filterFilter', function(filterFilter) {
return {
restrict: 'E',
templateUrl: 'todo-list.html',
scope: {
todos: '='
},
link: function (scope, element, attrs) {
// scope.todos is bound
// scope.filteredTodos is not!
scope.filteredTodos = filterFilter(scope.todos, { completed: false });
}
};
}]);