Created
November 25, 2013 03:13
-
-
Save PetersonDave/7635743 to your computer and use it in GitHub Desktop.
Example Angular Factory for obtaining Sitecore items
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory('profileservice', function ($http) { | |
var items = {}; | |
var myProfileService = {}; | |
myProfileService.addItem = function (item) { | |
items.push(item); | |
}; | |
myProfileService.removeItem = function (item) { | |
var index = items.indexOf(item); | |
items.splice(index, 1); | |
}; | |
myProfileService.getProfiles = function () { | |
return items; | |
}; | |
myProfileService.update = function (itemid, params) { | |
console.log(params); | |
var url = '-/item/v1/?sc_itemid=' + itemid; | |
$http.put(url, params); | |
}; | |
myProfileService.get = function (callback) { | |
var url = '-/item/v1/?scope=s&query=/sitecore/content/Home/Repository/*'; | |
$http.get(url) | |
.then(function (res) { | |
items = res.data.result.items; | |
callback(); | |
}); | |
}; | |
return myProfileService; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment