簡體   English   中英

BootstrapDialog和angularJS包括html

[英]BootstrapDialog and angularJS including html

我正在使用https://github.com/nakupanda/bootstrap3-dialog在我的Web應用程序上顯示對話框。

$scope.importFileWithSettings = function(){
                BootstrapDialog.show({
                        type: BootstrapDialog.TYPE_INFO,
                        message: "<div ng-include=\"'importform.html'\"></div>",
                        title: 'Title',
                });
            }; 

importform.html在同一目錄中。 當對話框顯示時,它不顯示importform.html內容。 正確的做法(我對angularJS和bootsrap比較陌生)?

您可以使用angularjs的腳本組件,這是包括模板的最佳方法...

<script type="text/ng-template" id="exampleTemplateId">
   Content of the template.
</script>

然后在您的ng-include指令中使用它的ID

<div ng-include=\"'exampleTemplateId'\"></div>

有關更多詳細信息,您可以檢查文檔

更新

您可以為此目的使用angularjs的$ templateCache服務...

在您的run塊中,您可以像這樣使用此服務

var myApp = angular.module('myApp', []);
myApp.run(function($templateCache) {
  $templateCache.put('exampleTemplateId', 'This is the content of the template');
}); 

並如上所述,在ng-inlucde再次使用它

根據文檔,這應該起作用:

$scope.importFileWithSettings = function(){
    BootstrapDialog.show({
            type: BootstrapDialog.TYPE_INFO,
            message: "$('<div></div>').load('importform.html')",
            title: 'Title',
    });
}; 

暫無
暫無

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

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