簡體   English   中英

Bootstrap模態和AngularJS

[英]Bootstrap modal and AngularJS

我在我的應用程序中使用AngularStrap 我想實現Bootstrap的模式功能。 問題是我無法使其顯示我的template模態。 這是通向朋克的鏈接 我的模板ID為test ,我通過template='#test'引用(如文檔中的解釋),但出現錯誤: Uncaught TypeError: Cannot set property 'display' of undefined

docs針對template規定了以下內容:

如果提供,則覆蓋默認模板,可以是遠程URL或緩存的模板ID。

模板可以從遠程源加載,也可以直接在腳本標簽中定義。 所有模板都是通過$templateCache實例加載的。 因此,要顯示模態,您需要將模態的定義更改為:

<script type="text/ng-template" id="test">
    <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"></h4>
                </div>
                <div class="modal-body" ng-bind="content"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" ng-click="$hide()">Close</button>
                </div>
            </div>
        </div>
    </div>
</script>

更新了插件以演示。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM