我对angularjs很新,我有以下代码。由于某种原因ng-click
没有触发。我见过各种类似的问题,但我没有弄到我在这里做错了什么。控制台上也没有错误。感谢
控制器
.controller("eventsExample", function ($scope) {
var technologies = [
{ techname: "Angularjs", likes: 0, dislikes: 0 },
{ techname: "Asp.net", likes: 0, dislikes: 0 },
{ techname: "JavaScript", likes: 0, dislikes: 0 },
{ techname: "HTML5/CSS3", likes: 0, dislikes: 0 }
];
$scope.technologies = technologies;
$scope.inscrementLikes = function (technology) {
technology.Likes++;
}
$scope.inscrementDisLikes = function (technology) {
technology.Dislikes++;
}
})
HTML
<div ng-controller="eventsExample">
<table>
<thead>
<tr>
<th>Technology</th>
<th>Likes</th>
<th>Dislikes</th>
<th>Hit Like/Dislike</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="technology in technologies">
<td> {{technology.techname}} </td>
<td> {{technology.likes}} </td>
<td> {{technology.dislikes}} </td>
<td>
<input type="button" value="Like" ng-click="inscrementLikes(technology)" />
<input type="button" value="Dislike" ng-click="inscrementDisLikes(technology)" />
</td>
</tr>
</tbody>
</table>
</div>