gpt4 book ai didi

javascript - 无法实例化模块 myModule

转载 作者:行者123 更新时间:2023-12-01 03:06:28 24 4
gpt4 key购买 nike

Uncaught Error: [$injector:modulerr] Failed to instantiate module myModule due to: Error: [$injector:nomod] Module 'myModule' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

    <head>
<script src="Scripts/angular.js"></script>
<script src="Scripts/Script.js"></script>
</head>

<body ng-controller="myController">
<div>
<table>
<thead>
<tr>
<th>Name</th>
<th>Likes</th>
<th>DisLikes</th>
<th>Likes/DisLikes</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="technology in technologies">
<td>{{ technology.name }}</td>
<td>{{ technology.likes }}</td>
<td>{{ technology.dislikes }}</td>
<td>
<input type="button" value="Like" ng-click="incrementLikes(technology)">
<input type="button" value="Dislike" ng-click="incrementDislikes(technology)">
</td>
</tr>
</tbody>
</table>
</div>

</body>
</html>




var app = angular.module("myModule", [])



app.controller("myController", function($scope){
var technologies = [{name:"C#", likes:0, dislikes:0},
{name:"ASP.NET", likes:0, dislikes:0},
{name:"SQL Server", likes:0, dislikes:0},
{name:"Angular JS", likes:0, dislikes:0},];

$scope.technologies = technologies;

$scope.incrementLikes = function(technology){
technology.likes++;
}

$scope.incrementDislikes = function(technology){
technology.dislikes++;
}


});

最佳答案

您尚未在 html 模板中定义 ng-app="myModule"。

在 html 或 body 标记中定义它,然后它应该开始工作。

关于javascript - 无法实例化模块 myModule,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46138615/

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