Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <body ng-app="TestApp" ng-controller="Test">
- <ul>
- <li ng-repeat="o in array">
- <div id="name">{{ o.name }}</div>
- <div id="remove" ng-bind-html="o.remove"></div>
- </li>
- </ul>
- <fieldset>
- <input ng-model="inputname">
- <button ng-click="addRow(inputname)">Add row</button>
- </fieldset>
- </body>
- angular.module('TestApp', []).controller("Test", function($scope, $sce) {
- $scope.array = [{name: "Test1"},{name: "Test2"},{name: "Test3"},{name: "Test4"}]
- $scope.addRow = function(name){
- var a = { name: name,
- remove: $sce.trustAsHtml("<button ng-click='removeRow($index)' </button>")
- }
- $scope.array.push(a)}
- $scope.remove = function(index) {
- $scope.array.splice(index, 1)}
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement