Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div ng-app="spApp">
- <div ng-controller="spListCtrl">
- <table width="100%" cellpadding="10" cellspacing="2">
- <thead>
- <th>First Name</th>
- <th>Last Name</th>
- <th>Email</th>
- <th>CellPhone</th>
- <th>Update</th>
- </thead>
- <tbody>
- <tr ng-repeat="item in Contacts">
- <td class="align-center">{{item.FirstName}} </td>
- <td class="align-center">{{item.Title}}</td>
- <td class="align-center">{{item.Email}}</td>
- <td class="align-center">{{item.CellPhone}}</td>
- <td class="align-center"><button ng-click="ShowNewForm(item)">Изменить</button></td>
- </tr>
- </tbody>
- </table>
- </div>
- <div ng-controller="spListCtrl" style="display:none" id="formNew">
- <form name="newitemForm" >
- <fieldset>
- <p>Изменение</p>
- <p><label for="newTitle">Last Name</label>
- <input id="newTitle" ng-model="nitem.Title" required placeholder="Введите новую фамилию"></p>
- <p><label for="newFirstName">First Name</label>
- <input id="newFirstName" ng-model="nitem.FirstName" required placeholder="Введите новое имя"/></p>
- <p><label for="newCellPhone">CellPhone</label>
- <input id="newCellPhone" ng-model="nitem.CellPhone" required placeholder="Введите новый телефон"/></p>
- <p><label for="newEmail">Email</label>
- <input id="newEmail" ng-model="nitem.Email" required placeholder="Введите новый Email"/></p>
- <button type="submit" ng-click="UpdateItem(nitem,newitemForm)">Готово</button>
- </fieldset>
- </form>
- </div>
- spApp.controller('spListCtrl', function spListCtrl($scope,dataService){
- $scope.Contacts=dataService.getContacts();
- $scope.ShowNewForm = function (item){
- newitem=item;
- $scope.nitem=newitem;
- $('#formNew').show();
- };
- $scope.UpdateItem = function (item,newitemForm){
- $scope.Contacts=dataService.updateContacts(endpointUrl,itemPayload);
- $('#formNew').hide();
- };
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement