TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Mohit Kapoor
1.6k
94
20.1k
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
Reply
Answers (
2
)
ng-resource with angular js
ng-table pagenation not update after delete or add new recor