大佬们,求助!angularjs定义ngapp时报错

南明北月 2018-03-29 04:43:38
html

<!DOCTYPE html>
<html lang="en" ng-app="routerApp">
<head>
<meta charset="utf-8" />
<meta name="renderer" content="webkit">
<title>首页</title>
<link rel="stylesheet" href="../../bowercss/bowercss.css" />
<link rel="stylesheet" href="../../css/index.css">
<script type="text/javascript" src="../../js/angular.min.js"></script>
<script type="text/javascript" src="../../js/angular-ui-router.min.js"></script>
<script type="text/javascript" src="../../js/app.js" ></script>
</head>
<body>
<div class="index_head">
<div class="menu">
<ul class="nav">
<li><a>首页</a></li>
<li><a>税务查询</a></li>
<li><a>对账</a></li>
<li><a>其他</a></li>
</ul>
</div>

</div>
</body>
</html>



app.js

var routerApp = angular.module("routerApp", ['']);

routerApp.config(function ($stateProvider, $urlRouterProvider) {

$urlRouterProvider.when("", "/index");

$stateProvider
.state("index", {
url: "/index",
templateUrl: "index.html"
})
.state("tax-yz", {
url:"/tax-yz",
templateUrl: "tax-yz.html"
});
});

在谷歌浏览器F12调试的时候一直报错,Failed to instantiate module routerApp due to:
Error: [$injector:modulerr] http://errors.angularjs.org/1.6.9/$injector/modulerr?p0=&...)
at http://localhost:8866/js/angular.min.js:1:556
at http://localhost:8866/js/angular.min.js:1:14549
at ut (http://localhost:8866/js/angular.min.js:1:991)
at i (http://localhost:8866/js/angular.min.js:1:14103)
at http://localhost:8866/js/angular.min.js:1:14289
at ut (http://localhost:8866/js/angular.min.js:1:991)
at i (http://localhost:8866/js/angular.min.js:1:14103)
at Pt (http://localhost:8866/js/angular.min.js:1:16233)
at i (http://localhost:8866/js/angular.min.js:1:7975)
at V (http://localhost:8866/js/angular.min.js:1:8286

官网给出的文档是这么说的
Description
This error occurs when a module fails to load due to some exception. The error message above should provide additional context.

A common reason why the module fails to load is that you've forgotten to include the file with the defined module or that the file couldn't be loaded.

Using ngRoute
In AngularJS 1.2.0 and later, ngRoute has been moved to its own module. If you are getting this error after upgrading to 1.2.x or later, be sure that you've installed ngRoute.

Monkey-patching AngularJS's ng module
This error can also occur if you have tried to add your own components to the ng module. This has never been supported and from 1.3.0 it will actually trigger this error. For instance the following code could trigger this error.

angular.module('ng').filter('tel', function (){});

但是找了半天问题,angularjs引入的没问题,我把app.js删除了 只要添加ng-app标签会报错
...全文
626 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
南明北月 2018-03-29
  • 打赏
  • 举报
回复
我用了nodejs,但对nodejs不熟悉

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧