Failed to load script with angle (ng-view)

0

I'm doing a design with angular js and using the design lite (mdl) material for the layout. Some features of mdl require a javascript file to work, but this file has some loading, sometimes not. I believe the browser ends up loading the mdl javascript file before angular loading the content into ng-view. Does anyone know how I can fix this?

    
asked by anonymous 16.06.2017 / 18:33

1 answer

2

Whoever goes through this problem follows the solution.

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

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);
            }
          }
        }
      }
    }
    
23.06.2017 / 20:37