gpt4 book ai didi

AngularJS 错误注入(inject)器模块rr

转载 作者:行者123 更新时间:2023-12-02 21:41:27 25 4
gpt4 key购买 nike

我正在尝试运行这个 AngularJS 教程示例,控制台显示:未捕获错误:[$injector:modulerr]

问题出在哪里?

<div class="container" data-ng-app="demoApp">
<div>
<h3>Adding Module Configuration and Routing</h3>

<div data-ng-view=""></div>
</div>
</div>

<script src="angular-1.2.3/angular.min.js"></script>
<script src="angular-1.2.3/angular-route.min.js"></script>

<script>
var demoApp = angular.module('demoApp', ['ngRoute']);

demoApp.config(function ($routeProvider) {
$routeProvider
.when('/',
{
controller: 'SimpleController',
templateUrl: urlBase + '7. Partial1.html'
})

.when('/partial2',
{
controller: 'SimpleController',
templateUrl: 'Partial/view1.html'
})
.otherwise({ redirectTo: '/' });
});

demoApp.controller('SimpleController', function ($scope) {
$scope.customers = [
{ name: 'Dave Jones', city: 'Phoenix' },
{ name: 'Jamie Riley', city: 'Atlanta' },
{ name: 'Heedy Wahlin', city: 'Chandler' },
{ name: 'Thomas Winter', city: 'Seattle' }
];
});
</script>

最佳答案

您需要从 ng-view 属性中删除 =""

关于AngularJS 错误注入(inject)器模块rr,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20363020/

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