未捕获的误差角度未定义



当我尝试从localhost8000加载我的索引.html页面时,我收到以下错误。未捕获的错误角度未在主页面的第 2 行定义.js。

索引.html:

<!DOCTYPE html>
<html lang='en' ng-app='App'>
<head>
<meta charset="utf-8">
<script src = 'angular/angular.js'></script>
<script src = 'angular-route/angular-route.js'></script>
<script src = 'js/main.js'></script>
<title></title>
</head>
<body>
<ng-view></ng-view> <!-- Allows loading of partials-->
</body>
</html>
Main.js page:
// Will handle our ng-routes
var app = angular.module('App', ['ngRoute'])
// Configure the partials
app.config(function($routeProvider) {
$routeProvider.when('/', {
templateUrl: '/partials/_ninjas.html', // Allows us to move around and see all the ninjas
});
});

我的代码中是否有我没有看到的错别字。我仍在参加在线编码训练营来学习编码,因此任何提示将不胜感激:)

尝试确保角度库正确加载 代码似乎没问题

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.5/angular-route.js"></script>
<script src="main.js"></script>
</head>
<body ng-app="App">
<ng-view></ng-view>
<!-- Allows loading of partials-->
<script>
var app = angular.module('App', ['ngRoute'])
// Configure the partials
app.config(function($routeProvider) {
$routeProvider.when('/', {
template: '<div>Hello</div>', // Allows us to move around and see all the ninjas
});
});
</script>
</body>
</html>

测试代码

该错误意味着您没有加载角度。

取代

<script src = 'angular/angular.js'></script>

有了这个:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.5/angular.min.js"></script>

看看它是否有效。

相关内容

  • 没有找到相关文章

最新更新