Marcin Majewski
Marcin Majewski

Reputation: 1047

BootstrapDialog and angularJS including html

I am using https://github.com/nakupanda/bootstrap3-dialog to show dialogs on my webapp.

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

importform.html is in the same directory. When the dialog shows it does not show importform.html content. How to do it right (I am relatively new to angularJS and bootsrap)?

Upvotes: 0

Views: 897

Answers (2)

Poyraz Yilmaz
Poyraz Yilmaz

Reputation: 5857

you can use script component of angularjs it is best way to include templates...

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

then in you ng-include directive use it with its id

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

for more details you can check docs

UPDATE

You can use $templateCache service of angularjs for this purpose...

in your run block you can use this service like this

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

and again use it in ng-inlucde as I stated above

Upvotes: 1

Endre Simo
Endre Simo

Reputation: 11551

According to documentation this should work:

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

Upvotes: 0

Related Questions