2
Answers

Why I am unable to update likes/dislike ?

Mohit Kapoor

Mohit Kapoor

8y
350
1
0 error but still code not works.
 
 
_____________________HTMLfile___________________________________
<!DOCTYPE html>
<html ng-app="myModule">

<head>

<script src="angular.js"></script>
<script src="main.js"></script>
<title>AngularJS</title>
<meta charset="utf-8" />
</head>

<body style="font-family:'Cambria Math';">

<div ng-controller="myController">

<table>

   <thead>
  <tr>
  <th>Language</th>
<th>Likes</th>
<th>Dislikes</th>
<th>Like/Dislike</th>
</tr>
<tr ng-repeat="myindex in technologies">
<td>{{ myindex.name }}</td>
<td>{{ myindex.likes }}</td>
<td>{{ myindex.dislikes }}</td>
<td>
<input type="button" value="Like" ng-click=" incrementlikes(myindex) "/>
<input type="button" value="Dislike" ng-click=" incrementdislikes(myindex) " />

</td>

</tr>

</thead>
</table>

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

 ------------------------main.js------------------------------------------------
/// <reference path="angular.min.js" />

var myApp = angular

.module("myModule", [])
.controller("myController",function ($scope) {

var technologies = [

{ name: "C", likes: 0, dislikes: 0 },
{ name: "C++", likes: 0, dislikes: 0 },
{ name: "C#", likes: 0, dislikes: 0 },
{ name: "Objective-C", likes: 0, dislikes: 0 },

];
$scope.technologies = technologies;

var incrementlikes = function (technology) {

technology.likes++;

};
var incrementdislikes = function (technology) {
technology.dislikes++;
};



});

 
 
 

Attachment: code.zip

Answers (2)