0

As given in the link http://angular-ui.github.io/bootstrap ( select modal from Directive drop down on top), there is a parameter called windowTemplateUrl which is used to over ride the modal content. So, in case we are using this, what to give in templateUrl or template, as one of these is required for calling the open function of modal. For e.g. the code is given below.

$scope.open = function(){
  var modalInstance = $modal.open({
      windowTemplateUrl : '/client/content.html'
  })
}

If I run the code as above, it gives error that templateUrl or template is required. So, how do I use windowTemplateUrl.

3
  • Do you want to open modal in separate Browser window? Commented Jul 11, 2014 at 11:07
  • No, it should be on the same page, just over the modal backdrop or overlay Commented Jul 11, 2014 at 11:08
  • This link might be usefull , popdevelop.com/2014/07/… Commented Oct 28, 2015 at 6:47

3 Answers 3

8

windowTemplateUrl is a template for window decoration: https://github.com/angular-ui/bootstrap/blob/master/template/modal/window.html

You still need to supply modal's content (using template or templateUrl) that you would like to see decorated.

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

9 Comments

Well, in that case, is there a way that I can avoid the regular modal window which comes up with white background (as shown in the link above itself, after clicking on open) and supply my own modal content, which could be anywhere on the page, not just centered.
Sure, you just do whatever decoration with whatever CSS you want and then content will be placed inside the provided decoration template.
Well, would it be possible to give a small sample code i.e. what to write in open function. That would really help me a lot. Thanks in advance.
@whyAto8 sure, just send a plunk with what you've tried so far
Here is the plunk - plnkr.co/edit/cWJkz2GjAjNE3JcgakGq?p=preview , its not my actual code, just a demo kind of. I havent included the parameter windowTemplateUrl, as i dont know how to use it. The content in customModal.html should appear instead of the custom modal content. Please let me know how to do that. Thank you.
|
2

This is how windowTemplateUrl is working

$scope.open = function () {

var modalInstance = $modal.open({
  templateUrl:'myModalContent.html',
  windowTemplateUrl: 'customModal.html',
  controller: 'ModalInstanceCtrl',
  resolve: {
  params: function(){
     return {
        title: 'Custom title 2'
           };
         }
      }
   });
};

Original version of angular-ui (not working)

Modificated version of angular-ui (working)

9 Comments

How can we set value in customModal.html, both {{title}} and {{params.title}} didn't worked?
@danielrvt So why I reported a bug to the angularui isssues page :)
I want to modify the modal template also the dark overlay. How can I can put multiple files in windowTemplateUrl?
This works for me, since I couldn´t determine the fullpath of default windowTemplateUrl on my dynamic route it was a lot easier to implement a custom one. Thanks.
|
0

First, you should use either base tag in you html documents or do not use relative urls.

Angular does not know about virtual directories so when path to you site looks like mysite.com/MySite there is a chance of getting into troubles.

pkozlowski.opensource has already given you an answer. Be also aware that you can provide an id of template instead of real url if you'd like to. In that case template must be declared like this:

<script type="text/ng-template" id="TemplateId">
    ...template...
</script>

Comments

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.