Angular script loading failure (ng-view)

Asked

Viewed 922 times

0

I’m doing an angular js design and using the lite design material (mdl) for the layout. Some MDL files need a javascript file to work but this file has to load, sometimes not. I believe that the browser ends up loading the mdl javascript file before the angular load the content in ng-view. Does anyone know how I can fix this?

1 answer

2


To those who go through this problem, follow the solution.

In the script tag, which imports the mdl javascript enter the attribute Defer.

I also used a Directive to upgrade the html tags that require the mdl script:

function mdlUpgrade($window, $timeout) {
      return {
        restrict: 'A',
        compile: function () {
          return {
            post: function postLink(scope, element) {
              $timeout(function () {
                if (angular.isDefined($window.componentHandler)) {
                  $window.componentHandler.upgradeElements(element[0])
                }
              }, 0);
            }
          }
        }
      }
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.