With Angularjs 1.x you could easily switch html templates on a button click between edit/readonly modus. The ng-include directive was the key.
<table>
<thead>
<th>Name</th>
<th>Age</th>
<th></th>
</thead>
<tbody>
<tr ng-repeat="contact in model.contacts" ng-include="getTemplate(contact)">
</tr>
</tbody>
</table>
The get getTemplate function executes this code:
$scope.getTemplate = function (contact) {
if (contact.id === $scope.model.selected.id) return 'edit';
else return 'display';
};
which again lead to one of those templates to be active in the UI:
DISPLAY
<script type="text/ng-template" id="display">
<td>{{contact.name}}</td>
<td>{{contact.age}}</td>
<td>
<button ng-click="editContact(contact)">Edit</button>
</td>
</script>
EDIT
<script type="text/ng-template" id="edit">
<td><input type="text" ng-model="model.selected.name" /></td>
<td><input type="text" ng-model="model.selected.age" /></td>
<td>
<button ng-click="saveContact($index)">Save</button>
<button ng-click="reset()">Cancel</button>
</td>
</script>
https://jsfiddle.net/benfosterdev/UWLFJ/
With Angular 2 RC 4 there exist no n-include.
How would I do the same feature just with Angular 2 RC4 ?