Skip to content

Commit

Permalink
Add k-ng-delay which allows to delay widget initialization.
Browse files Browse the repository at this point in the history
Ticket 825918
  • Loading branch information
mishoo committed Jun 4, 2014
1 parent f5b022d commit 367b7a0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion angular-kendo.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
kOptions : true,
kRebind : true,
kNgModel : true,
kNgDelay : true,
};
return function(scope, element, attrs, widget, origAttr) {
var role = widget.replace(/^kendo/, '');
Expand Down Expand Up @@ -183,7 +184,19 @@

++KENDO_COUNT;

timeout(function() {
var kNgDelay = attrs.kNgDelay;

timeout(function createIt() {
if (kNgDelay) return (function(){
var unregister = scope.$watch(kNgDelay, function(newValue, oldValue){
if (newValue !== oldValue) {
unregister();
kNgDelay = null;
timeout(createIt); // XXX: won't work without `timeout` ;-\
}
}, true);
})();

// if k-rebind attribute is provided, rebind the kendo widget when
// the watched value changes
if (attrs.kRebind) {
Expand Down

0 comments on commit 367b7a0

Please sign in to comment.