Here is my solution:
I created second directive: Input (restricted for Element, so every input has one). In Input directive I broadcast every change to element's scope:
link: function (scope, element: JQuery, attrs: ng.IAttributes) {
if(typeof attrs.ngModel !== "undefined") {
scope.$watch(attrs.ngModel, function (newValue, oldValue) {
scope.$broadcast('valueChanged'+scope.$id, newValue, oldValue);
});
}
}
scope.$id is used just for be sure that event name is unique for every input.
Now, in any other directive I can listen event of changing any input:
link: function (scope, element:JQuery, attrs:ng.IAttributes) {
//My input is last child everytime..
var children = element.find("input");
var lastInput = angular.element(children[children.length - 1]);
var lastInputScope = lastInput.scope();
var unregister = lastInputScope.$on('valueChanged' + lastInputScope.$id,
function (event, newValue, oldValue) {
//do whatever you want...
});
scope.$on('$destroy', function () {
unregister();
});
}