gpt4 book ai didi

javascript - 0x800a1391 - JavaScript 运行时错误 : 'angular' is undefined

转载 作者:行者123 更新时间:2023-12-02 13:47:03 25 4
gpt4 key购买 nike

我的controller.js有以下代码:

  var myController = angular.module('myApp.controllers', [])

我的 Services.js 具有以下代码:

  angular.module('myApp.services', [])

当我运行我的应用程序时,代码“var myController = angular.module('myApp.controllers', [])”给出了以下异常:0x800a1391 - JavaScript 运行时错误:“Angular ”未定义。

谁能告诉我出了什么问题吗?我们将不胜感激您的帮助:)

顺便说一句,这是我的网络应用程序的 html 代码

<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PathFinding.js</title>
<link rel="stylesheet" href="./css/style.css" />
<link rel="stylesheet" href="./lib/themes/jquery.ui.all.css" />
<script src="./js/angular.js"></script>
<script type="text/javascript" src="path/to/bower_components/pathfinding/pathfinding-browser.min.js"></script>
<script type="text/javascript" src="./lib/raphael-min.js"></script>
<script type="text/javascript" src="./lib/es5-shim.min.js"></script>
<script type="text/javascript" src="./lib/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="./lib/state-machine.min.js"></script>
<script type="text/javascript" src="./lib/async.min.js"></script>
<script type="text/javascript" src="./lib/ui/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="./lib/ui/jquery.ui.widget.min.js"></script>
<script type="text/javascript" src="./lib/ui/jquery.ui.mouse.min.js"></script>
<script type="text/javascript" src="./lib/ui/jquery.ui.draggable.min.js"></script>
<script type="text/javascript" src="./lib/ui/jquery.ui.accordion.min.js"></script>
<script type="text/javascript" src="./lib/ui/jquery.ui.slider.min.js"></script>
<script type="text/javascript" src="./lib/pathfinding-browser.min.js"></script>
<script type="text/javascript" src="./js/view.js"></script>
<script type="text/javascript" src="./js/controller.js"></script>
<script type="text/javascript" src="./js/Services.js"></script>
<script type="text/javascript" src="./js/mainApp.js"></script>

<script type="text/javascript" src="./js/panel.js"></script>
<script type="text/javascript" src="./js/main.js"></script>


</head>
<body>
<ion-modal-view>
<ion-content>
<ion-scroll zooming="true" overflow-scroll="false" direction="xy" style="width: 100%; height:100%;"
scrollbar-x="false" scrollbar-y="false">

<div class="scroll-container" id="draw_area" style="width: 100%; height:100%; background: url('PathFindingMap.png') no-repeat ">

</div>
</ion-scroll>
</ion-content>
</ion-modal-view>

<button style="margin-bottom:10px;margin-left:30px;margin-right:30px;" id="button1" class="control_button" type="button">Search!</button>

<div style="visibility: hidden;" id="algorithm_panel" class="panel right_panel">

<div class="accordion">

<h3 id="astar_header"></h3>

<div id="astar_section" class="finder_section">

</div>
</div>
</div>
<div style="visibility: hidden;" id="play_panel" class="panel right_panel">

</div>
<div id="stats"></div>

</body>
</html>

最佳答案

构建 Angular 应用程序的错误方法这就是您需要定义模块的方式

var app = angular.module('myApp',[])

这就是您需要在controller.js中添加 Controller 的方式由于您已经定义了模块,因此无需提供依赖项

    var app = angular.module('myApp')
app.controller('myController',function(){
// Here is your controller content
})

以下是在 service.js 中添加服务的方法

var app = angular.module('myApp')
app.service('myService',function(){
// Here is your service content (this.method);
})

您的代码会出现错误,因为您已定义模块两次,即定义其依赖项[]

关于javascript - 0x800a1391 - JavaScript 运行时错误 : 'angular' is undefined,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41312925/

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