gpt4 book ai didi

angularjs - Angular + require.js :Failed to instantiate module

转载 作者:行者123 更新时间:2023-12-02 23:37:46 24 4
gpt4 key购买 nike

我的代码:index.html

<html ng-app='Arrows'>
<script data-main="main" src="require.js"></script>
<div ng-controller="My">
{{status}}
</div>

和main.js文件

    require(["jquery","underscore","backbone",
"marionette","angular"], function($ ,_,Backbone,Marionette,angular){

debugger

var app = angular.module("Arrows")
angular.element(document).ready(function () {
angular.bootstrap(document, ['Arrows']);
});

app.controller('My', function($scope) {
$scope.status = 'hello! Its working!';
});
})

我有问题:

Uncaught Error: [$injector:modulerr] Failed to instantiate module Arrows due to: Error: [$injector:nomod] Module 'Arrows' 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 中删除 ng-app 指令。您已经手动引导它。

<script data-main="main" src="require.js"></script>
<div ng-controller="My">
{{status}}
</div>

这对于代码来说已经足够了。

顺便说一句,我不会在同一个应用程序中使用 Backbone 和 Angular。

关于angularjs - Angular + require.js :Failed to instantiate module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25679293/

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