Skip to content

Instantly share code, notes, and snippets.

@AndrewO
Created April 20, 2013 01:04
Show Gist options
  • Select an option

  • Save AndrewO/5424267 to your computer and use it in GitHub Desktop.

Select an option

Save AndrewO/5424267 to your computer and use it in GitHub Desktop.

Revisions

  1. AndrewO created this gist Apr 20, 2013.
    16 changes: 16 additions & 0 deletions app.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    var app = angular.module('plunker', []);

    app.controller('MainCtrl', function($scope) {
    $scope.dudes=[
    {name:'Leonardo'},
    {name:'Donatello'},
    {name:'Raphael'},
    {name:'Michaelango'}
    ];

    // I wouldn't recommend this. See: http://plnkr.co/edit/K5vcB4v2OLGDNXzG2iNV?p=preview
    $scope.addDude = function() { $scope.dudes.push({}); }
    $scope.removeDude = function(dude) {
    $scope.dudes = _($scope.dudes).without(dude);
    }
    });
    12 changes: 12 additions & 0 deletions index.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    <body ng-controller="MainCtrl">
    <form>
    <button ng-click="addDude()">Add</button>
    <ul ng-repeat="dude in dudes">
    <li>
    <input ng-model="dude.name"/>
    <button ng-click="removeDude(dude)">Delete</button>
    </li>
    </ul>
    </form>
    <pre><code>{{dudes|json}}</code></pre>
    </body>