繁体   English   中英

Angular $ injector:unpr中的模态

[英]Modal in Angular $injector:unpr Unknown

我在尝试在角度中使用模态时遇到了这个问题

$modalProvider <- $modal <- User.Ctlr

这是我的app.js

'use-strict';

var App = angular.module('App', ['ui.bootstrap']);

这是我的控制器

“严格使用”;

App.controller('User.Ctlr', ['$scope', '$modal', '$http', function ($scope, $modal, $http) { 
}]);

这是我的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>

我不了解可能出什么问题,当我没有模态时,它曾经可以正常工作,所以我的控制器与变量$ modal完全相同。

您需要注入$modalInstance而不是modal

app.controller('User.Ctlr', function ($scope, $modalInstance, $http)
{
   //Use modalInstance
});

演示

我变了

<script src="/scripts/lib/ui-bootstrap-tpls-2.2.0.min.js"></script>

对于

<script src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.9.0.js"></script>

现在它可以正常工作了! 谢谢

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM