Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Removing data from a list on click using angular

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 398
    Comment on it

    Hi all,

    Below is an example to remove names from a list using ng-click.

    Here is a simple form for editing, adding or removing user name, all of these methods are declared on the controller.
    These methods can easily be called from the angular markup. Any changes to the data are automatically reflected in the View without the need for a manual update.

    <html ng-app="nameApp">
        <meta charset="utf-8">
        <title>Angular.js Example</title>
        <script src="//"></script>
          var nameApp = angular.module('nameApp', []);
          nameApp.controller('NameCtrl', function ($scope){
            $scope.names = ['Larry', 'Curly', 'Moe'];
            $scope.addName = function() {
              $scope.enteredName = '';
            $scope.removeName = function(name) {
              var i = $scope.names.indexOf(name);
              $scope.names.splice(i, 1);
      <body ng-controller="NameCtrl">
          <li ng-repeat="name in names">{{name}}
          <a href="" ng-click="removeName(name)">remove</a></li>
        <form ng-submit="addName()">
          <input type="text" ng-model="enteredName">
          <input type="submit" value="add">

    For more reference visit below link:-

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: