未捕获的错误: [$injector:modulerr] - 角度 ng-include
Uncaught Error: [$injector:modulerr] - Angular ng-include
我正在使用ng-include将一些HTML页面附加到AngularJS中的一个HTML页面。
查找主页面代码.html
<!DOCTYPE html>
<html ng-app="Test">
<head>
<link rel="stylesheet" href ="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
</head>
<body ng-controller="userController">
<div class="container">
<div ng-include="'test1.htm'"></div>
<div ng-include="'test2.htm'"></div>
</div>
</body>
</html>
测试1.html代码
<!DOCTYPE html>
<html>
<head>
</head>
<body>
Full Name:
</body>
</html>
我的代码似乎没有错。但是当我在浏览器中加载它时,什么都没有显示,我得到控制台错误说,
未捕获的错误: [$injector:模块] http://errors.angularjs.org/1.2.26/$injector/modulerr?p0=Test&p1=Error%3A%2...gleapis.com%2Fajax%2Flibs%2Fangularjs%2F1.2.26%2Fangular.min.js%3A18%3A387)
请帮助我解决问题。
错误在这里
<html ng-app="Test">
您必须定义一个新模块才能将其用作应用程序
类似的东西
主模块.js
var app =angular.module("myApp",[]);
app.controller("myCTRL"["$scope",function($scope){
}]);
然后将该JS文件包含在您的项目中以使用它诸如此类
<!DOCTYPE html>
<html ng-app="myApp">
<head>
<link rel="stylesheet" href ="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script src="assets/js/MainModule.js"></script>
</head>
<body ng-controller="myCTRL">
<div class="container">
<div ng-include="'test1.htm'"></div>
<div ng-include="'test2.htm'"></div>
</div>
</body>
</html>
你必须
在 head tag 中包含 'angular route java 脚本文件。喜欢这个
<head>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script src= "http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.route.js"></script>
</head>
相关文章:
- AngularJS ng include dons'不起作用
- ng include导致角度问题
- AngularJS ng include won'不知什么原因不起作用
- 如何将动态文件名传递给ng-include
- 有没有办法在AngularJS中强制重新加载递归ng-include
- 使用ng-include渲染Angular模板时出现问题
- 每个ng-include模板都有单独的变量
- AngularJS:如何使用ng-include将javascript文件加载到部分中
- 阻止“ng include”创建孤立的作用域.AngularJS
- 如何扩展 Angularjs ng-include 指令
- 在 ng-include 中使用变量作为表达式
- ng-class 在 angularJs 中由 ng-include 包含的文件内不起作用
- 模块化与性能与性能与角度应用程序中的ng-include
- 未捕获的错误: [$injector:modulerr] - 角度 ng-include
- 使用ng-include调用控制器时AngularJS路由解析
- angular js中嵌套ng include内的表单
- 在AngularJS中动态切换ng include和ng控制器
- 使用ng-include重用以前实例化的模板
- 页面不可滚动,其中ng include=“”;函数()"-该代码已不再使用
- 如何在双大括号表示法{{}}中使用ng-include和html文件