I'm having this problem trying to use modals in angular
$modalProvider <- $modal <- User.Ctlr
Here's my app.js
'use-strict';
var App = angular.module('App', ['ui.bootstrap']);
Here's my controller
'use strict';
App.controller('User.Ctlr', ['$scope', '$modal', '$http', function ($scope, $modal, $http) {
}]);
Here's my HTML
<body ng-app="App">
<div class="container" ng-controller="User.Ctlr">
</div>
</body>
<script src="/scripts/lib/jquery-1.9.1.min.js"></script>
<script src="/scripts/lib/angular.min.js"></script>
<script src="/scripts/lib/bootstrap.js"></script>
<script src="/scripts/lib/ui-bootstrap-tpls-2.2.0.min.js"></script>
<script src="/scripts/app/app.js"></script>
<script src="/scripts/app/controllers/userCtrl.js"></script>
I'm not understanding what could be wrong, it used to work properly when I didn't have modals, so my controller was exactly the same but the variable $modal.
You need to inject $modalInstance
instead of modal
app.controller('User.Ctlr', function ($scope, $modalInstance, $http)
{
//Use modalInstance
});
I changed
<script src="/scripts/lib/ui-bootstrap-tpls-2.2.0.min.js"></script>
For
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.9.0.js"></script>
And now it's working properly! Thanks
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.