8

For some reason the modal box works just fine but it does not load any templates I specify.

My Controller has this code;

var brnSearchModal = $modal({ scope: $scope, template: "app/rrn/searchBrn.html", contentTemplate: false, html: true, show: false });

$scope.showModal = function () {
    brnSearchModal.$promise.then(brnSearchModal.show);
};

My HTML looks like this;

<button data-ng-click="showModal()" type="button" class="btn btn-info" data-animation="am-fade-and-slide-top">
    BRN Lookup
</button>

And my template is in a file and looks like this;

<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">Hello, World!</h4>
            </div>
            <div class="modal-body" ng-bind="content">Lorem ipsum dolor.</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" ng-click="$hide()">Close</button>
            </div>
        </div>
    </div>
</div>

There is no error everything seems to be working fine but the template does not load. If I debug angular-strap at one point the template is loaded but then disappears in and leaves a blank modal.

Lukasz
  • 8,710
  • 12
  • 44
  • 72

4 Answers4

2

Remove ng-show="title", ng-bind="title" from the template.

Shaunak D
  • 20,588
  • 10
  • 46
  • 79
dcdrns
  • 103
  • 1
  • 10
0

Try adding the bs-modal attribute: see examples

<button data-ng-click="showModal()" type="button" class="btn btn-info" data-animation="am-fade-and-slide-top" bs-modal="brnSearchModal">
    BRN Lookup
</button>

Otherwise use the data-template attribute directly without using the JS to show the modal:

<button type="button" class="btn btn-info" data-animation="am-fade-and-slide-top" data-template="app/rrn/searchBrn.html" bs-modal="modal">
    BRN Lookup
</button>

I think when you put bs-modal="modal" modal is somehow pre-defined in the angular-strap library.

Fourat
  • 2,366
  • 4
  • 38
  • 53
0

you should remove ng-show="title" , ng-show="content" or ng-bind="title" from the template. You should make sure that the template has no ng-show.

veljasije
  • 6,722
  • 12
  • 48
  • 79
Python Basketball
  • 2,320
  • 3
  • 24
  • 47
0

I know it is an old question, but in case others are looking for a solution to the same problem. I found I had to explicitly set templateUrl to falsy when setting template to an html string

Mike Hanson
  • 266
  • 1
  • 8