gpt4 book ai didi

javascript - 简单的 Angular 应用程序不起作用

转载 作者:数据小太阳 更新时间:2023-10-29 05:18:36 27 4
gpt4 key购买 nike

我正在尝试创建基本的 Angular 应用程序,但它抛出了一个错误

<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script type="text/javascript">
var angularApp = angular.module('angularApp', []);
angularApp.controller('Ctrl', function($scope) {});
</script>
</head>
<body>
<div ng-app ng-controller="Ctrl"></div>
</body>
</html>

错误:

Error: [ng:areq] http://errors.angularjs.org/1.4.3/ng/areq?p0=Ctrl&p1=not%20a%20function%2C%20got%20undefined
at Error (native)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:6:416
at Sb (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:22:18)
at Qa (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:22:105)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:79:497
at x (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:59:501)
at S (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:60:341)
at g (https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:54:384)
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:53:444
at https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js:19:481'

我做错了什么?

最佳答案

您必须为 ng-app 提供您的应用名称:

<div ng-app="angularApp" ng-controller="Ctrl"></div>

关于javascript - 简单的 Angular 应用程序不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31576034/

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