0

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)?

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

But I have to place <script>...</script> in line in order to run it. Is it possible to place it in external file?
@MarcinMajewski u can use $templateCache service in your run config... let me add it on to answer...
0

According to documentation this should work:

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

1 Comment

I am getting error because it is trying to get "myhost:port/importform.html", but not the html that is in the same directory as script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.