I have an upgrade to angular 1.5 and now you want to use components instead of directives. My problem is that my ngModel will not run ng-change after I change my value. all solutions found did not match my problem.
i has the following component
<date-picker ng-model="$ctrl.fromDate" ng-change="$ctrl.updateData()">
</date-picker>
my date picker directive looks like (I reduced the code because there are a lot of irrelevant things) I use babelify for my code
import template from './datePicker.jade';
import moment from 'moment';
class datePicker {
constructor(
$scope,
$element,
$attrs
) {
console.log(this);
this.$scope = $scope;
this.$element = $element;
this.$attrs = $attrs
this.initialize();
}
initialize() {
this.updateView();
}
changeDate(day) {
this.ngModel = day;
this.updateView();
}
datePicker.$inject = [
'$scope',
'$element',
'$attrs'
];
export default {
controller: datePicker,
bindings: {
ngModel: '=',
},
template: template(),
};
My solution with a directive method defined the scope.updateModel function in the link function, which sets the view value of my model. It works, but its ugly, I no longer want to use link functions