Here's how I solved the problem in case anyone else comes across this (mdl race condition using angular):
- Download the material.js library after loading the header directive
- wait for
window.componentHandler - Then run
window.componentHandler.upgradeAllRegistered();
Full code (placed in the 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); })(); }
source share