How to add a Technology, which is entered in the text box as a record when i click on add button in ng-click action required for my table?
var app = angular.module("myApp",[]);
app.controller("myCtrl", function($scope){
$scope.technologies = [
{name:'C#', likes:'0', dislikes:'0'},
{name:'.Net', likes:'0', dislikes:'0'},
{name:'Java', likes:'0', dislikes:'0'},
{name:'MySQL', likes:'0', dislikes:'0'}
];
$scope.incrementlikes = function(technology){
technology.likes++;
}
$scope.incrementdislikes = function(technology){
technology.dislikes++;
}
$scope.addRecord = function(text){
$scope.technology.push({name:text, likes:'0', dislikes:'0'});
}
});
table,
th,
tr,
td {
border: 2px solid #fff;
border-collapse: collapse;
}
td,
th {
background: #006688;
color: #fff;
padding: 5px;
}
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<div ng-app="myApp" ng-controller="myCtrl">
<table style="width:400px;">
<tr>
<td align="right">Enter Technologies : </td>
<td><input type="text" /></td>
<td><input type="button" value="Add" ng-click="addRecord(technology);" /></td>
</tr>
</table>
<table style="width:400px;">
<thead>
<tr>
<th>Name</th>
<th>Likes</th>
<th>Dislikes</th>
<th>Likes / Dislikes</th>
</tr>
<tr ng-repeat="technology in technologies">
<td>{{technology.name}}</td>
<td align="center">{{technology.likes}}</td>
<td align="center">{{technology.dislikes}}</td>
<td align="center">
<input type="button" value="Likes" ng-click="incrementlikes(technology);" />
<input type="button" value="Dislikes" ng-click="incrementdislikes(technology);" />
</td>
</tr>
</thead>
</table>
</div>
$scope.technologies