0

I've been searching on the internet how to use UI Bootstrap with AngularJS but I won't work.

This is my code right now:

<html> <head> <script src="componenten/bower_components/angular/angular.js"></script> <script src="componenten/bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js"></script> <script src="componenten/bower_components/angular-bootstrap/ui-bootstrap.min.js"></script> </head> <body ng-app="ui.bootstrap.demo"> <div ng-controller="ModalDemoCtrl"> <script type="text/ng-template" id="myModalContent.html"> <div class="modal-header"> <h3 class="modal-title">I'm a modal!</h3> </div> <div class="modal-body"> <ul> <li ng-repeat="item in items"> <a href="#" ng-click="$event.preventDefault(); selected.item = item">{{ item }}</a> </li> </ul> Selected: <b>{{ selected.item }}</b> </div> <div class="modal-footer"> <button class="btn btn-primary" type="button" ng-click="ok()">OK</button> <button class="btn btn-warning" type="button" ng-click="cancel()">Cancel</button> </div> </script> <button type="button" class="btn btn-default" ng-click="open()">Open me! </button> <button type="button" class="btn btn-default" ng-click="open('lg')">Large modal</button> <button type="button" class="btn btn-default" ng-click="open('sm')">Small modal</button> <button type="button" class="btn btn-default" ng-click="toggleAnimation()">Toggle Animation ({{ animationsEnabled }})</button> <div ng-show="selected">Selection from a modal: {{ selected }}</div> </div> </body> </html> 

I already tried to add almost every script and css file but it will never work.

0

1 Answer 1

3

You need to include Angular Bootstrap as a dependency:

angular.module('ui.bootstrap.demo', ['ui.bootstrap']); 

And please delete the ui-bootstrap.min.js beacuse ui-bootstrap-tpls.min.js contains both the code and template.

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

5 Comments

Okey that fixed a lot already, no more errors when I start the page but when I click a button I get errors again.
This is the error that is shown in the console "[$compile:tpload] Failed to load template: template/modal/window.html (HTTP status: 404 Not Found)"
Please remove the ui-bootstrap.min.js script tag. You only need the ui-bootstrap-tpls.min.js one, which contains both code and templates.
I think you need to change the order in which you are loading the bootstrap JS files.
@SimoEndre no... you use one or the other...not both.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.