[英]Angular js Error: [$injector:modulerr] Failed to instantiate module ngroute due to:
I am trying to create a simple angularjs app with ngroute. 我正在尝试使用ngroute创建一个简单的angularjs应用程序。 but I am getting the following error.
但我收到以下错误。 please help me.
请帮我。
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular-resource.js"></script>
<script src="route.js"></script>
</head>
<body ng-app="myApp">
<div ng-view></div>
</body>
</html>
Javascript: 使用Javascript:
var app = angular.module('myApp', ['ngroute']);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.when("/", {
templateUrl: "app,html",
controller: "mycont"
});
}]);
app.controller('mycont', function($scope) {
$scope.message = "hello";
});
There is no such module ngroute
, it's ngRoute
(and similar ngResource
). 没有这样的模块
ngroute
,它是ngRoute
(和类似的ngResource
)。 Case matters here. 案例很重要。 Correct module definition would be:
正确的模块定义为:
var app = angular.module('myApp', ['ngRoute']);
Also watch, app,html
in template name. 还可以在模板名称中观看,
app,html
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.