Here is an simple example to add and delete list using angular ng-click
Html -
<div ng-app="nameApp" ng-controller="TitleCtrl">
<ul>
<li ng-repeat="name in names">{{name}}
<a href="" ng-click="removeName(name)">remove</a></li>
</ul>
<form ng-submit="addName()">
<input type="text" ng-model="enteredName">
<input type="submit" value="+">
</form>
</div>
Script -
var nameApp = angular.module('nameApp', []);
nameApp.controller('TitleCtrl', function ($scope){
$scope.names = ['FindNerd'];
$scope.addName = function() {
$scope.names.push($scope.enteredName);
$scope.enteredName = '';
};
$scope.removeName = function(name) {
var i = $scope.names.indexOf(name);
$scope.names.splice(i, 1);
};
});
Output -
0 Comment(s)