2014-07-24 41 views
7

由于某些原因,模式框工作得很好,但它不会加载我指定的任何模板。Angular-Strap Modal不会加载模板

我的控制器有这个代码;

var brnSearchModal = $modal({ scope: $scope, template: "app/rrn/searchBrn.html", contentTemplate: false, html: true, show: false }); 

$scope.showModal = function() { 
    brnSearchModal.$promise.then(brnSearchModal.show); 
}; 

我的HTML看起来像这样;

<button data-ng-click="showModal()" type="button" class="btn btn-info" data-animation="am-fade-and-slide-top"> 
    BRN Lookup 
</button> 

而我的模板是在一个文件中,看起来像这样;

<div class="modal" tabindex="-1" role="dialog"> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 
      <div class="modal-header" ng-show="title"> 
       <button type="button" class="close" ng-click="$hide()">&times;</button> 
       <h4 class="modal-title" ng-bind="title">Hello, World!</h4> 
      </div> 
      <div class="modal-body" ng-bind="content">Lorem ipsum dolor.</div> 
      <div class="modal-footer"> 
       <button type="button" class="btn btn-default" ng-click="$hide()">Close</button> 
      </div> 
     </div> 
    </div> 
</div> 

没有错误一切似乎工作正常,但模板不加载。如果我在一个点上调试角度带,则模板会加载,但会消失并留下空白模态。

回答

0

尝试添加BS-模式属性:看examples

<button data-ng-click="showModal()" type="button" class="btn btn-info" data-animation="am-fade-and-slide-top" bs-modal="brnSearchModal"> 
    BRN Lookup 
</button> 

否则使用数据模板的直接属性,而不使用JS以显示模式:

<button type="button" class="btn btn-info" data-animation="am-fade-and-slide-top" data-template="app/rrn/searchBrn.html" bs-modal="modal"> 
    BRN Lookup 
</button> 

我认为,当你把bs-modal="modal" modal是以某种方式在角度绑定库中预定义的。

2

从模板中删除ng-show="title",ng-bind="title"

+0

必须接受的答案 –

0

你应该删除ng-show="title“,ng-show="content"或从模板ng-bind="title"。您应该确保该模板没有ng-show

+0

,如果你想显示模式的标题,请删除NG -bind-HTML = “标题” –