Skip to content

Instantly share code, notes, and snippets.

@PetersonDave
Created November 25, 2013 03:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PetersonDave/7635743 to your computer and use it in GitHub Desktop.
Save PetersonDave/7635743 to your computer and use it in GitHub Desktop.
Example Angular Factory for obtaining Sitecore items
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