0

我在我的指令中使用 ng-include 在函数中

function initPopup(includingHtml) {
    ui.debugLog('Init popup');
    $popupContainer = angular.element('<div class="b-popup"><div class="b-popup__bg"></div><div class="b-popup__content">'+includingHtml+'</div></div>');
    $compile($popupContainer)($scope,function(){
        body.append($popupContainer);
    });
}

function attachUserLoginForm() {
    ui.debugLog('Init login form');
    initPopup('<div onload="formLoaded()" ng-include="'+"'/templates/forms/login.html'"+'"></div>');
}

function link(scope,element, attrs) {
    $scope = $rootScope.$new();
    $scope.formLoaded = formLoaded;
    $element = element;

    switch(attrs.cdPopup) {
        case 'login':
            $($element).on('click',function(e){
                attachUserLoginForm();
                bindContainerClose();
                e.preventDefault();
            });
        break;
    }
}
return {
    link: link
};

这个函数渲染代码

<div class="b-popup ng-scope">
  <div class="b-popup__bg">
  </div>
  <div class="b-popup__content">
     <!-- ngInclude: '/templates/forms/login.html' -->
  </div>
</div>

即使发送了对模板的请求,也不会加载进一步的停止模板..

4

0 回答 0