Skip to content

Instantly share code, notes, and snippets.

@dwaligora
Created February 7, 2014 00:06
Show Gist options
  • Save dwaligora/8855084 to your computer and use it in GitHub Desktop.
Save dwaligora/8855084 to your computer and use it in GitHub Desktop.
'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);
}
};
})
@Tarunkumar0
Copy link

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