Mohit Kapoor

Mohit Kapoor

  • NA
  • 93
  • 18.7k

Why I am unable to update likes/dislike ?

May 28 2016 2:21 AM
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)