I'm adding data with this method:

.controller("addItemsController", function ($scope, $http) {
                var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getByTitle('MyContacts')/items";
                var vm = $scope;
                var requestDigest = $("#__REQUESTDIGEST").val()
                vm.addContact = function () {
                    return $http({
                        headers: { "accept": "application/json; odata=verbose", "X-RequestDigest": requestDigest, "content-Type": "application/json;odata=verbose" },
                        method: "POST",
                        url: url,
                        data: {
                            'Title': vm.LastName,
                            'FirstName': vm.FirstName,
                            "__metadata": { "type": "SP.Data.MyContactsListItem" }
                    .catch(function (message) {
                        console.log("addContact() error: " + message);
                    function saveContact(data, status, headers, config) {
                        alert("Item Added Successfully");
                        return data.data.d;

What I want is to update the data on the page after adding the new item.

I've tried $scope.contacts.push(data); as suggested several places, but contacts comes back underfined.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.