ng-include not load template

时间:2014-05-15 08:23:03

标签: angularjs angularjs-directive angularjs-ng-include

我在我的指令中使用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>

即使发送了模板请求,也没有加载停止模板..

0 个答案:

没有答案