0

I am using AngularStrap in my application. I am tying to implement the modal feature of bootstrap. The problem is that I can't make it to show up my template modal. Here is a link to plunker. My template's id is test and I am referring in (like explained in the docs) by template='#test' but I am getting an error: Uncaught TypeError: Cannot set property 'display' of undefined.

vlio20
  • 8,955
  • 18
  • 95
  • 180

1 Answers1

3

The docs state the following for template:

If provided, overrides the default template, can be either a remote URL or a cached template id.

In angular a template can either be loaded from a remote source or defined directly in a script tag. All templates are loaded via an instance of $templateCache. So, to make your modal show you need to change the definition of your modal to look like:

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

Updated plunker to demonstrate.

Dean Ward
  • 4,793
  • 1
  • 29
  • 36
  • Looks like it follows the same principle - create a `script` element with an identifier and reference that from the `content-template` of your modal. Updated [plunker](http://plnkr.co/edit/AIvMtKyaU0lp376qc1YD) – Dean Ward Jul 07 '14 at 13:39