When I try to close Angular Bootstrap Modal inside Angular 1.5 component, it throws Error: $injector:unpr Unknown Provider.
It works fine, if I use Controller instead of Component. Am I missing something?
<!doctype html>
<html ng-app="app">
<head>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.5.3/angular-animate.js"></script>
<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.2.js"></script>
<script src="example.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<h1>Angular Modal Demo</h1>
<my-content></my-content>
</body>
</html>
Script
angular.module('app', ['ngAnimate', 'ui.bootstrap']);
angular.module('app')
.component('myContent', {
template: 'I am content! <button type="button" class="btn btn-default" ng-click="$ctrl.open()">Open Modal</button>',
controller: function ($uibModal) {
this.open = function () {
$uibModal.open({
template: '<my-modal></my-modal>'
});
};
}
});
angular.module('app')
.component('myModal', {
template: '<div class="modal-body">I am a modal! <button class="btn btn-warning" type="button" ng-click="$ctrl.close()">Close Modal</button></div>',
controller: function ($uibModalInstance) {
this.close = function () {
$uibModalInstance.dismiss('cancel');
};
}
});