javascript - ng change with custom directive -



javascript - ng change with custom directive -

javascript code directive

angular.directive('uidatepicker', [function() { homecoming { restrict: 'ea', scope: { ngmodel: '=ngmodel', ngchange: '=ngchange' }, templateurl: 'complete/date-picker.tmp.html', replace: true, require: 'ngmodel', link: function(scope, elem, attrs, ngmodel) { if(scope.ngmodel !== undefined) { scope.datepicker = new datepicker(new date(scope.ngmodel)); } else { scope.datepicker = new datepicker(); } scope.ngmodel = scope.datepicker.value; } } }])

javascript code controller

angular.controller('main', ['$scope', function($scope) { $scope.change = function(value) { console.log(value); }; $scope.value = 1000; }])

html code

<div ng-controller="main"> <ui-date-picker ng-model="date" ng-change="change(value)"></> </div>

and question: how ng-change work ?. ngmodel still work !

javascript angularjs angularjs-directive

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -