The text of this article is not in this database — only its details are. Read it on the old site: AngularJS in SharePoint 2013: Part 1
11 Comments
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
The text of this article is not in this database — only its details are. Read it on the old site: AngularJS in SharePoint 2013: Part 1
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment.
Dhayanand KalimidiPosted Nov 26, 2018, 6:24 AM
Really help full for beginners
Sushi BurritoPosted Feb 22, 2017, 4:27 PM
For people having issues: Create a list titled Test. Update the script to only update the Title field. Then try it. -------webpart code----- <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.15/angular.min.js"></script> <script> function ContactsCtrl($scope) { $scope.contact = { Title: "" }; $scope.addContact = function ($event) { var x = $scope.contact; $event.preventDefault(); var clientContext = new SP.ClientContext.get_current(); var web = clientContext.get_web(); var list = web.get_lists().getByTitle('Test'); // create the ListItemInformational object var listItemInfo = new SP.ListItemCreationInformation(); // add the item to the list var listItem = list.addItem(listItemInfo); // Assign Values for fields listItem.set_item('Title', x.Title); listItem.update(); clientContext.executeQueryAsync( Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed) ); }; onQuerySucceeded = function () { alert('Successfully added the contact'); } onQueryFailed = function (sender, args) { alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace()); } } </script> <h1>TEST:</h1> <br /> <div ng-app=""> <div ng-controller="ContactsCtrl"> <strong>Title</strong> <input type="text" ng-model="contact.Title" /><br /> <br /> <input type="submit" value="Submit" ng-click="addContact($event)" /> </div> </div>
Pankaj GuptaPosted Nov 30, 2016, 4:11 AM
The code is not running at all
Shivu SKPosted Jun 18, 2016, 8:36 PM
Do we need to add the SP..js and SP.Runtime.js file reference ?
Shivu SKPosted Jun 18, 2016, 8:35 PM
Hi Vijay
Chaitanya KrishnaPosted May 27, 2015, 2:08 AM
hi i hav tried the updated code but no items were saving in the list.list name, filed names all are correct.
Vishwas GoswamiPosted Oct 16, 2014, 5:07 AM
i tried the code but it is not reflecting data in my list. can you tell me why ?
Gaurav AroraPosted Sep 18, 2014, 5:10 AM
Good One !! But one mistake in 2nd code block line 17 ; var listlistItem = list.addItem(listItemInfo); you write two times list in variable name listlistItem instead of listItem ..please edit your code block for further reference
Lakshmanan Sethu SankaranarayanPosted Jul 31, 2014, 2:08 AM
Good one Vijai:)