gpt4 book ai didi

javascript - Uncaught Error : [$injector:modulerr] http://errors. angularjs.org/1.4.8/$injector/modulerr?p0=myApp&p1=Error

转载 作者:行者123 更新时间:2023-11-29 10:37:43 27 4
gpt4 key购买 nike

this is the error i m getting.这个问题被问了很多次。但是下面的代码在在线编译器中运行良好,但在我的本地系统中运行不佳,即使系统已连接到互联网,它也显示未定义 Angular

angular.module('myApp',[]).controller('myCtrl',function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
<html>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.7/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">

First Name: <input type="text" ng-model="firstName"/><br>
Last Name: <input type="text" ng-model="lastName"/><br>
<br>
Full Name: {{firstName + " " + lastName}}

</div>
</body>
</html>

最佳答案

像这样改变你的 Controller ,

  var app = angular.module('myApp', ['ngRoute']);
app.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.4.8/angular-route.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
First Name:
<input type="text" ng-model="firstName" />
<br>Last Name:
<input type="text" ng-model="lastName" />
<br>
<br>Full Name: {{firstName + " " + lastName}}
</div>
<script>
var app = angular.module('myApp', ['ngRoute']);
app.controller('myCtrl', function($scope) {
$scope.firstName = "John";
$scope.lastName = "Doe";
});
</script>

关于javascript - Uncaught Error : [$injector:modulerr] http://errors. angularjs.org/1.4.8/$injector/modulerr?p0=myApp&p1=Error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34132824/

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