ng-include does not work after using a policy

0

I needed to make a dynamic controller, but when I use the directive data-ng-dynamic-controller my ng-include does not work does anyone know what it can be?

  

ng-dynamic-controller directive

appModule.directive('ngDynamicController', ['$compile', '$parse',function($compile, $parse) {
    return {
        scope: {
            name: '=ngDynamicController'
        },
        restrict: 'A',
        terminal: true,
        priority: 100000,
        link: function(scope, elem, attrs) {
            elem.attr('ng-controller', scope.name);
            elem.removeAttr('data-ng-dynamic-controller');
            elem.removeAttr('ng-dynamic-controller');

            $compile(elem)(scope);
        }
    };
}]);
  

HTML

<div class="page-content-wrapper" data-ng-controller="masterpageController as mpc">

    <div class="page-content" ng-dynamic-controller="mpc.getController()">
            <div class="page-head">
                <div class="page-title">
                    <h1>{{pageTitle}}
                        <small>{{pageDescription}}</small>
                    </h1>
                </div>
            </div>
            <ul class="page-breadcrumb breadcrumb">
                <li>
                    <a href="javascript:;">AppName</a>
                    <i class="fa fa-circle"></i>
                </li>
                <li>
                    <span class="active">{{pageTitle}}</span>
                </li>
            </ul>
            <!-- Não funciona... -->
            <div data-ng-include="mpc.getHtmlFile()"></div>

        </div>
</div>

Note: mpc is my masterpageController , and both methods exist and the return is correct, but when I use ng-dynamic-controller the getHtmlFile() method is not called. If I remove the ng-dynamic-controller it normally works getHtmlFile()

    
asked by anonymous 20.04.2017 / 06:13

1 answer

0

I've been able to sort out guys, apparently it's terminal removed it priority and it worked normally.

appModule.directive('ngDynamicController', ['$compile', '$parse',function($compile, $parse) {
    return {
        scope: {
            name: '=ngDynamicController'
        },
        restrict: 'A',
        terminal: true,
        priority: 100000,
        link: function(scope, elem, attrs) {
            elem.attr('ng-controller', scope.name);
            elem.removeAttr('data-ng-dynamic-controller');
            elem.removeAttr('ng-dynamic-controller');

            $compile(elem)(scope);
        }
    };
}]);
    
20.04.2017 / 06:29