-
-
Save anilsingh581/0b62de647e7dc6d9fab7 to your computer and use it in GitHub Desktop.
Revisions
-
HasAndries revised this gist
Jul 18, 2012 . 1 changed file with 13 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,18 +3,21 @@ angular.module('bDatepicker', []). return { require: '?ngModel', restrict: 'A', link: function($scope, element, attrs, controller) { var updateModel; updateModel = function(ev) { element.datepicker('hide'); element.blur(); return $scope.$apply(function() { return controller.$setViewValue(ev.date); }); }; if (controller != null) { controller.$render = function() { element.datepicker().data().datepicker.date = controller.$viewValue; element.datepicker('setValue'); element.datepicker('update'); return controller.$viewValue; }; } return attrs.$observe('bDatepicker', function(value) { @@ -23,11 +26,11 @@ angular.module('bDatepicker', []). if (angular.isObject(value)) { options = value; } if (typeof(value) === "string" && value.length > 0) { options = angular.fromJson(value); } return element.datepicker(options).on('changeDate', updateModel); }); } }; }); -
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ angular.module('bDatepicker', []). directive('bDatepicker', function(){ return { require: '?ngModel', restrict: 'A', link: function($scope, element, attrs, ngModelCtrl) { var originalRender, updateModel; updateModel = function(ev) { return $scope.$apply(function() { return ngModelCtrl.$setViewValue(ev.date); }); }; if (ngModelCtrl != null) { originalRender = ngModelCtrl.$render; ngModelCtrl.$render = function() { originalRender(); return element.datepicker.date = ngModelCtrl.$viewValue; }; } return attrs.$observe('bDatepicker', function(value) { var options; options = {}; if (angular.isObject(value)) { options = value; } if (typeof(value) === "string") { options = angular.fromJson(value); } return element.datepicker(options).on('changeDate', updateModel); }); } }; });