未知的提供者:$modalProvider <- AngularJS 的 $modal 错误

Unknown provider: $modalProvider lt;- $modal error with AngularJS(未知的提供者:$modalProvider lt;- AngularJS 的 $modal 错误)
本文介绍了未知的提供者:$modalProvider <- AngularJS 的 $modal 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试实现引导模式窗口时不断收到此错误消息.可能是什么原因造成的?我已经复制/粘贴了 http://angular-ui.github.io/bootstrap/#/modal 这里.

I keep receiving this error as I'm trying to implement bootstrap Modal window. What could be the cause of it? I've copy/pasted everything from http://angular-ui.github.io/bootstrap/#/modal here.

推荐答案

当您为控制器、服务等编写依赖项,而您尚未创建或包含该依赖项时,会发生这种错误.

This kind of error occurs when you write in a dependency for a controller, service, etc, and you haven't created or included that dependency.

在这种情况下,$modal 不是已知服务.听起来您在引导角度时没有将 ui-bootstrap 作为依赖项传递.angular.module('myModule', ['ui.bootstrap']); 另外,为了安全起见,请确保您使用的是最新版本的 ui-bootstrap (0.6.0).

In this case, $modal isn't a known service. It sounds like you didn't pass in ui-bootstrap as a dependency when bootstrapping angular. angular.module('myModule', ['ui.bootstrap']); Also, be sure you are using the latest version of ui-bootstrap (0.6.0), just to be safe.

该错误在 0.5.0 版本中引发,但更新到 0.6.0 确实使 $modal 服务可用.因此,请更新到 0.6.0 版本,并确保在注册模块时需要 ui.boostrap.

The error is thrown in version 0.5.0, but updating to 0.6.0 does make the $modal service available. So, update to version 0.6.0 and be sure to require ui.boostrap when registering your module.

回复您的评论:这就是您注入模块依赖项的方式.

Replying to your comment: This is how you inject a module dependency.

<!-- tell Angular what module we are bootstrapping -->
<html ng-app="myApp" ng-controller="myCtrl">

js:

// create the module, pass in modules it depends on
var app = angular.module('myApp', ['ui.bootstrap']);

// $modal service is now available via the ui.bootstrap module we passed in to our module
app.controller('myCtrl', function($scope, $uibModal) {

});

更新:

$modal 服务已重命名为 $uibModal.

使用 $uibModal 的示例

// create the module, pass in modules it depends on
var app = angular.module('myApp', ['ui.bootstrap']);

// $modal service is now available via the ui.bootstrap module we passed in to our module
app.controller('myCtrl', function($scope, $uibModal) {
    //code here
});

这篇关于未知的提供者:$modalProvider &lt;- AngularJS 的 $modal 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

How to sort a array of object based on two properties and check the rage is sequential?(如何根据两个属性对对象数组进行排序,并检查范围是否连续?)
Untyped function calls may not accept type arguments - Angular 5 http calls(非类型化函数调用可能不接受类型参数-角度5 http调用)
ReferenceError: Excel is not defined(ReferenceError:未定义Excel)
How to save two canvas(outer and inner) as png using fabric js in angular(如何保存两个画布(外部和内部)为PNG使用织物js的角度)
Access to #39;Set-Cookies#39; header in $http(访问$http中的Set-Cookies标头)
Adding lt;stronggt;/bold text in translated string using angular-translate(使用角度翻译在翻译后的字符串中添加lt;stronggt;/粗体文本)