gpt4 book ai didi

javascript - Angularjs ng-Grid注入(inject)错误

转载 作者:行者123 更新时间:2023-11-30 15:48:18 25 4
gpt4 key购买 nike

我在使用 ngGrid 时使用了以下代码。

var MyApp = angular.module("MyApp", ['ngGrid','ngRoute', 'ProductService']);

但它给了我以下错误。

angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module MyApp due to: Error: [$injector:modulerr] Failed to instantiate module ngGrid due to: Error: [$injector:nomod] Module 'ngGrid' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

根据堆栈溢出中的建议,我更改了我的代码如下。

var MyApp = angular.module("MyApp", ['ui.grid','ngRoute', 'ProductService']);

但我还是遇到了不同的错误。

angular.js:68 Uncaught Error: [$injector:modulerr] Failed to instantiate module MyApp due to: Error: [$injector:modulerr] Failed to instantiate module ui.grid due to: Error: [$injector:nomod] Module 'ui.grid' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

<html xmlns="http://www.w3.org/1999/xhtml" data-ng-app="MyApp"> <head><title></title>
<link href="Content/bootstrap.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="ng-grid.css" />
<script src="Scripts/jquery-1.9.1.js"></script>
<script src="Scripts/bootstrap.js"></script>
<script src="Scripts/angular.js"></script>
<script src="Scripts/angular-route.js"></script>
<script type="text/javascript" src="ng-grid-1.3.2.js"></script>
<script src="app.js"></script>
<script src="service.js"></script>
<script src="controller.js"></script>

有没有人知道如何注入(inject) ngGrid 并在 angularjs 应用程序中使用它?

谢谢。

最佳答案

将 ng-grid JS 文件添加到您的项目中:

<head lang="en">
<link rel="stylesheet" type="text/css" href="ng-grid.css" />
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="ng-grid-1.3.2.js"></script>
</head>

关于javascript - Angularjs ng-Grid注入(inject)错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39743476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com