Advertisement
akass

angular

Mar 12th, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <div ng-app="spApp">
  2.     <div ng-controller="spListCtrl">
  3.         <table width="100%" cellpadding="10" cellspacing="2">
  4.             <thead>
  5.            
  6.                 <th>First Name</th>
  7.                 <th>Last Name</th>
  8.                 <th>Email</th>
  9.                 <th>CellPhone</th>
  10.                 <th>Update</th>
  11.             </thead>
  12.             <tbody>
  13.                 <tr ng-repeat="item in Contacts">
  14.  
  15.                     <td class="align-center">{{item.FirstName}} </td>
  16.                     <td class="align-center">{{item.Title}}</td>
  17.                     <td class="align-center">{{item.Email}}</td>
  18.                     <td class="align-center">{{item.CellPhone}}</td>
  19.                     <td class="align-center"><button ng-click="ShowNewForm(item)">Изменить</button></td>
  20.                 </tr>
  21.             </tbody>
  22.         </table>
  23.     </div>
  24. <div ng-controller="spListCtrl" style="display:none" id="formNew">
  25.         <form name="newitemForm" >
  26.            
  27.             <fieldset>
  28.             <p>Изменение</p>
  29.             <p><label for="newTitle">Last Name</label>
  30.             <input id="newTitle" ng-model="nitem.Title" required placeholder="Введите новую фамилию"></p>
  31.             <p><label for="newFirstName">First Name</label>
  32.             <input id="newFirstName" ng-model="nitem.FirstName" required placeholder="Введите новое имя"/></p>
  33.             <p><label for="newCellPhone">CellPhone</label>
  34.             <input id="newCellPhone" ng-model="nitem.CellPhone" required placeholder="Введите новый телефон"/></p>
  35.             <p><label for="newEmail">Email</label>
  36.             <input id="newEmail" ng-model="nitem.Email" required placeholder="Введите новый Email"/></p>
  37.             <button type="submit" ng-click="UpdateItem(nitem,newitemForm)">Готово</button>
  38.             </fieldset>
  39.            
  40.         </form>
  41.     </div>
  42. spApp.controller('spListCtrl', function spListCtrl($scope,dataService){
  43.  
  44.     $scope.Contacts=dataService.getContacts();
  45.     $scope.ShowNewForm = function (item){
  46.  
  47.         newitem=item;
  48.         $scope.nitem=newitem;
  49.         $('#formNew').show();
  50.     };
  51.  
  52.  
  53.     $scope.UpdateItem = function (item,newitemForm){
  54.  
  55.         $scope.Contacts=dataService.updateContacts(endpointUrl,itemPayload);
  56.         $('#formNew').hide();
  57.     };
  58. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement