Created
February 7, 2014 00:06
-
-
Save dwaligora/8855084 to your computer and use it in GitHub Desktop.
This file contains 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 characters
'use strict'; | |
/** | |
* Mobiscroll directives set | |
* @type {*} | |
*/ | |
var mobiscroll = angular.module('mobiscroll', []); | |
/* | |
* Native style datetime picker | |
*/ | |
mobiscroll.directive('mobiscrollDate', function () { | |
return { | |
restrict: 'AE', | |
require: 'ngModel', | |
scope: { | |
model: '=ngModel' | |
}, | |
link: function (scope, elem, attrs, ngModel) { | |
var property = attrs.mobiscrollDate; | |
console.log(ngModel); | |
var options = { | |
onClose : function (valueText, btn, inst) { | |
if (btn !== 'set') return; | |
scope[property].valueText = valueText; | |
scope[property].value = angular.copy(inst.getValue()); | |
scope[property].values = angular.copy(inst.getValues()); | |
if (!scope.$$phase) scope.$apply(); | |
return true; | |
}, | |
onBeforeShow : function (inst) { | |
inst.option(scope[property].options); | |
} | |
}; | |
scope.$watch("model", function(value) { | |
ngModel.$viewValue = value; | |
elem.val(value); | |
}); | |
angular.extend(options, scope[property].options); | |
elem.mobiscroll()[scope[property].options.type](options); | |
elem.on('$destroy', function() { | |
elem.mobiscroll('destroy'); | |
}); | |
scope.scroller.call = function () { | |
elem.mobiscroll.apply(elem, arguments); | |
}; | |
} | |
}; | |
}); | |
/** | |
* Mobiscroll datepicker initializer. | |
*/ | |
.factory('datepicker', function(mobiscrollTemplateResolver) { | |
function provideDatePicker(type) { | |
return { | |
visible : true, | |
options : { | |
headerText: false, | |
showLabel: false, | |
show: false, | |
dateFormat: 'MM dd yy', | |
dateOrder: 'MM dd yy', | |
type: type, | |
theme: mobiscrollTemplateResolver.getTemplate(), | |
accent: 'none', | |
display: 'bottom', | |
mode: 'scroller', | |
endYear: 2050 | |
} | |
}; | |
} | |
return { | |
defineDatePicker: function(scope, property, type) { | |
scope[property] = provideDatePicker(type); | |
} | |
}; | |
}) |
Thanks a Lot but its not working Sir,
can u provide working Plunkr Link for this repo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi
Thank's a lot.
Is it possible that you create a 'plnkr' example?
Thank’s gain
Avi