简体   繁体   English

Angular $ injector:unpr中的模态

[英]Modal in Angular $injector:unpr Unknown

I'm having this problem trying to use modals in angular 我在尝试在角度中使用模态时遇到了这个问题

$modalProvider <- $modal <- User.Ctlr

Here's my app.js 这是我的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 这是我的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. 我不了解可能出什么问题,当我没有模态时,它曾经可以正常工作,所以我的控制器与变量$ modal完全相同。

You need to inject $modalInstance instead of modal 您需要注入$modalInstance而不是modal

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

DEMO 演示

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 谢谢

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

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