From fe85e6c313b90edfa1247fe1a606b4d676962c6f Mon Sep 17 00:00:00 2001 From: silverwolfx10 Date: Mon, 24 Nov 2014 20:45:01 -0200 Subject: [PATCH] Add ngModel for ngChange Work Add ngModel optional requirement for make ngChange Work, now just add ng-model and ng-change and be happy. --- app/scripts/datePicker.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/scripts/datePicker.js b/app/scripts/datePicker.js index 48a2e7d..3680a4f 100644 --- a/app/scripts/datePicker.js +++ b/app/scripts/datePicker.js @@ -30,13 +30,14 @@ Module.directive('datePicker', ['datePickerConfig', 'datePickerUtils', function //noinspection JSUnusedLocalSymbols return { // this is a bug ? + require:'?ngModel', template: '
', scope: { model: '=datePicker', after: '=?', before: '=?' }, - link: function (scope, element, attrs) { + link: function (scope, element, attrs, ngModel) { scope.date = new Date(scope.model || new Date()); scope.views = datePickerConfig.views.concat(); @@ -73,6 +74,10 @@ Module.directive('datePicker', ['datePickerConfig', 'datePickerUtils', function if ((!nextView || partial) || scope.model) { scope.model = new Date(scope.model || date); + //if ngModel , setViewValue and trigger ng-change, etc... + if(ngModel) + ngModel.$setViewValue(scope.model); + var view = partial ? 'minutes' : scope.view; //noinspection FallThroughInSwitchStatementJS switch (view) {