angularjs - Disable dates using factory response UI Bootstrap Datepicker -
I'm trying to disable a date in a Google Calendar UI bootstrap date picture if those dates are already 3 Or are more organized
', Function ($ http, $ q) {var Deffered = $ q.defer (); var data = []; var dates = {}; dates.async = function () {$ http.get (' http: / ' / Localhost: 7777 / event '). Civet (function (d) {data = d; deffered.resolve ();}); change instead.promis;}; dates.data = function () {return data;}; return Dates;}); A little more preprocessing is required in the list of dates, so I have a function that only puts dates that have 3 or more entries in a scope-variable: / P>
$ scope.occurences = ['2014-07-21', '2014-07-28'];
Now it is my default default UI now Bootstrap Date Picker Date Disabled Function:
// Disable Weekend Selection $ scope.disabled = Function (Date , Mode) {return (mode === 'day' & amp; (date.getDay () === 0] date.getDay () === 6 || $ scope.date_occurences.indexOf ($ filter ('date ') (Date,' Yay-MM-DD '))! == -1)); };
This works except for a small rugby, when the "idle" function is called by date picker, array is empty, estimating async callback is the reason i This is the first time because I select a date in the date picker because my dates are disabled
how the callback is received before the date picker disabled function, or how can I wait for it Am I After the callback comes, an option may be to refresh the Datepicker, but I'm not sure this function exists on the date picker.
I did not properly solve the above described above, but an alternative solution:
< P> 1 In a stack overflow remark, I used a small code that lets you call the corner-UI bootstrap date picture "Refresh View" by using a button or other type of action. Basically set up a new command `app.directive ('jmdpRefreshView', function) {var noop = function () {}; Var refreshDpOnNotify = function (dpCtrl) {return function () {DpCtrl.refreshView ();}}}; Return {Required: 'Date Picker', Link: Function (Scope, AMM, ethers, DPCTLL) {var RefreshPrinted = Scope [attrs.jmDpRefreshView]; Refresh Processes. Then (noop, noop, refresh depthone (dpCtrl));}}
}); `
To call refresh view functionality
$ scope.toggleDisableMode = function {dateDisableDeferred.notify (new date). GetTime ()); };
Toggle functionThisABelmode can be called through any type of operation, for example by using the button to disable dates from the server: "ng-click = 'toggleDisableMode ( ) ''
One more thing that can help you either you can preload your dates from the server
// preload $ scope.dates = Disable_dates (); Function disable_dates () {console.log ("disabled date function") dates. Then (function () {$ scope.data = Dates.data (); // whatever you want with your data}};}
or when you get data from the server You can call ".notify ()" to postpone and will be disabled upon completion.
function disable_dates () {console.log ("Disabled Date Function" ) Dates .asink (). Then (function () {$ scope.data = Dates.data (); //console.log($scope.data) / / whatever you prefer with your server data. // Note this line, disable function date Call. Disable Permission to (new date). GetTime ());}); }
This solution has been answered to this question and commented on there:
Comments
Post a Comment