我在我的指令中使用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>
即使发送了模板请求,也没有加载停止模板..