Run plugin after ng-view is loaded

0

I'm using the LocaStyle framework for development, so it runs certain plugin functions like jquery.mask.js and applies to the required elements.

However, sometimes it happens that the plugin runs before the view is loaded, causing it to have no effect on the page.

How can I check if Angular already loaded and view and only then load the script?

    
asked by anonymous 04.01.2015 / 19:43

2 answers

0

You will have to attach a controller to the page and it will execute the script when the view loads completely, like this:

$angular.module('app', ['ngRoute'])
  .config(function ($routeProvider) {
    $routeProvider.when('/', {
      templateUrl:'template/pag1.html',
      controller:'MyController'  //<- Controller anexado
    });
})
  .controller('MyController', function($scope) {
    $scope.$on('$viewContentLoaded', function () {
      //Defina as funções executadas assim que a view seja totalmente carregada
    });
});
    
05.01.2015 / 11:44
0

You can create a jquery pro plugins policy as explained in this article link

I think this is the best way

    
21.08.2015 / 12:42