If I create a service that does something in relation to the document that it runs on...how can I pass in the node id of this document?
So for example, consider in "UmbracoAngularBackofficePages" project, in PersonApiController.cs we got:
public Person GetById(int id)
{
var query = new Sql().Select("*").From("people").Where<Person>(x => x.Id == id);
return DatabaseContext.Database.Fetch<Person>(query).FirstOrDefault();
}
and then in person.resource.js we got:
getById: function (id) {
return $http.get("backoffice/Example/PersonApi/GetById?id=" + id);
},
In the first example I went through, there is a personpicker.controller.js file:
So instead of calling getAll(), if I wanted to get getById(with node id that this is running on), how can I make it so that whatever node I put this service on, it use the current id?
I realize it might not make sense why I would want to do exactly that, but I'm using these examples as a recipe to do something else, and I need to start off by passing in this current id. I can't see how to do it.
Get the current node into a service
Hi,
I am going through the various Angular/WebApi examples for creating Umbraco service...and watching some Angular tutorials...getting there...
So I got this example working.. https://github.com/perploug/UkFest-AngularJS-Demo
And I have moved onto this one which demonstrates CRUD operations: https://github.com/TimGeyssens/UmbracoAngularBackofficePages
Could someone more experienced tell me...
If I create a service that does something in relation to the document that it runs on...how can I pass in the node id of this document?
So for example, consider in "UmbracoAngularBackofficePages" project, in PersonApiController.cs we got:
and then in person.resource.js we got:
In the first example I went through, there is a personpicker.controller.js file:
So instead of calling getAll(), if I wanted to get getById(with node id that this is running on), how can I make it so that whatever node I put this service on, it use the current id?
I realize it might not make sense why I would want to do exactly that, but I'm using these examples as a recipe to do something else, and I need to start off by passing in this current id. I can't see how to do it.
Hmmm, I guess maybe in my .cs controller, in the method I want, I could just use umbraco node factory..something like...
So,. it's not really about getting the context from the Angular at all..?
is working on a reply...