Rinu

Rinu

  • NA
  • 24
  • 965

Loading the list item details using angular js.

Nov 13 2017 12:51 AM
Hi all,
 
I am new to angular JS and was able to create a form to submit the data to the list . Using the below code.
  1. <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script>    
  2. <script>  
  3.     window.onload = function () {  
  4.         alert('page');  
  5.     };  
  6.     function ContactsCtrl($scope) {  
  7.   
  8.         $scope.contact = { firstName: "", lastName: "", Location: "", Departmant: "" };  
  9.         $scope.addContact = function ($event) {  
  10.             var x = $scope.contact;  
  11.             $event.preventDefault();  
  12.   
  13.             if (x.Departmant == "HR") {  
  14.                 alert('pease select IT');  
  15.             }  
  16.             else {  
  17.   
  18.                 var clientContext = new SP.ClientContext.get_current();  
  19.                 var web = clientContext.get_web();  
  20.                 var list = web.get_lists().getByTitle('Contact Details');  
  21.   
  22.                 // create the ListItemInformational object    
  23.                 var listItemInfo = new SP.ListItemCreationInformation();  
  24.                 // add the item to the list    
  25.                 var listItem = list.addItem(listItemInfo);  
  26.                 // Assign Values for fields    
  27.                 listItem.set_item('Title', x.firstName);  
  28.                 listItem.set_item('firstName', x.firstName);  
  29.                 listItem.set_item('lastName', x.lastName);  
  30.                 listItem.set_item('fullName', x.firstName + " " + x.lastName);  
  31.                 listItem.set_item('Location', x.Location);  
  32.                 listItem.set_item('Departmant', x.Departmant);  
  33.   
  34.                 listItem.update();  
  35.   
  36.                 clientContext.executeQueryAsync(  
  37.                     Function.createDelegate(this, onQuerySucceeded),  
  38.                     Function.createDelegate(this, onQueryFailed)  
  39.                 );  
  40.             }  
  41.         };  
  42.   
  43.         onQuerySucceeded = function () {  
  44.             alert('Successfully updated the contact');  
  45.         }  
  46.   
  47.         onQueryFailed = function (sender, args) {  
  48.             alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());  
  49.         }  
  50.     }  
  51. </script>    
 i would know if there is a way to show an item details from the list to an angular js form just like above?. 
 
The senario is that A sharepoint designer  workflow email is to be sent to the users who will then  click on the link to access see or edit the list item. How do i do that?
 

Answers (1)