Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. <body ng-app="TestApp" ng-controller="Test">
  2. <ul>
  3. <li ng-repeat="o in array">
  4. <div id="name">{{ o.name }}</div>
  5. <div id="remove" ng-bind-html="o.remove"></div>
  6. </li>
  7. </ul>
  8. <fieldset>
  9. <input ng-model="inputname">
  10. <button ng-click="addRow(inputname)">Add row</button>
  11. </fieldset>
  12. </body>
  13.  
  14. angular.module('TestApp', []).controller("Test", function($scope, $sce) {
  15. $scope.array = [{name: "Test1"},{name: "Test2"},{name: "Test3"},{name: "Test4"}]
  16.  
  17. $scope.addRow = function(name){
  18. var a = { name: name,
  19. remove: $sce.trustAsHtml("<button ng-click='removeRow($index)' </button>")
  20. }
  21. $scope.array.push(a)}
  22. $scope.remove = function(index) {
  23. $scope.array.splice(index, 1)}
  24. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement