Strange bug.....
I have a race condition where my angularJS directives for header
and drawer
are compiling after material-design-lite initializes the layout.
It only seems to happen when I shut my wifi off and work offline. No remote resources are required, though google tag manager, and facebook connect plugin fail in the network tab.
Questions:
onload
of the page?I have already tried window.componentHandler.upgradeAllRegistered()
but that doesn't reinitialize the layout
Here's how I solved the problem in case anyone else runs into this (mdl race condition with angular):
window.componentHandler
window.componentHandler.upgradeAllRegistered();
Full code (placed in header directive)
function materialize(){
var script = document.createElement('script');
script.src = 'assets/js/material.js';
document.body.appendChild(script);
(function upgrade(){
if (!window.componentHandler){
return $timeout(upgrade, 200);
}
$timeout(window.componentHandler.upgradeAllRegistered);
})();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With