我在使用ng-include模板时出现问题,我在页面中显示了一个模式窗口,其中的内容取决于尝试注册的结果。
我正在使用ng-include来填写模态窗口的内容,例如:
<div class="md-modal md-effect-10" id="loginModal">
<div class="md-content">
<h3 ng-include = "loginTemplate.header"></h3>
<div ng-include = "loginTemplate.body"></div>
</div>
</div>
我的ajax登录请求的成功功能如下:
$scope.launchModal = function (respStr){
$scope.loginTemplate = {
header : "templates/loginModal/"+respStr+"/header.html",
body :"templates/loginModal/"+respStr+"/body.html"
};
$('#loginModal').addClass('md-show');
};
然而,发生的事情是,窗口在模板中没有显示任何内容,只有当我关闭窗口时才会请求模板。然后,如果我再次显示窗口:
$('#loginModal').addClass('md-show');
模板化的内容就在那里。
您可以在下面的链接中看到它的运行情况,您需要点击“注册”登录逻辑尚未连接。
有任何线索吗?
答案 0 :(得分:0)
问题是当您的modal
显示,您的网页header.html
和body.html
无法使用时,因为GET
该服务器页面的延迟时间很短。< / p>
您需要directive进行任何HTML
操作。因此,使用指令来显示您的模态
在HTML
<div my-modal class="md-effect-10" id="loginModal">
<div class="md-content">
<h3 ng-include = "loginTemplate.header"></h3>
<div ng-include = "loginTemplate.body"></div>
</div>
</div>
和myModal
指令
myApp.directive('myModal', function() {
return {
link: function(scope, element) {
element.addClass('md-show');
}
}
})