Accessing property on Ancestor documenttype from c...
# help-with-umbraco
s
I'm creating a custom property editor and I need to access a property on the nearest ancestor of a specific type. How do I do this in angular in latest v13 ?
c
Might not be the "perfect" answer but should be something along the lines of: Get the currentNode from:
Copy code
var currentNode = editorState.getCurrent()
Then use the entityResource from the backoffice API to get all of the ancestors of that current node.
Copy code
entityResource.getAncestors(currentNode.id, "Document")
 .then(function(ancestors) {
    // Filter for the ancestor you are looking for.
}
That should get you as far as something like this (Screenshot attached to this message): So then youd just need to probably do a find clause to get the ancestor with the metaData.ContentTypeAlias that you are looking for. Once you have that ancestor, take its ID and pass it to: contentResource.getById(ancestors ID here) Inside of the resulting response, you should get an object with the properties inside of it https://cdn.discordapp.com/attachments/1344277815805083691/1344281575184924723/image.png?ex=67c05747&is=67bf05c7&hm=629bfa32d4d00db16339db0e55613989ab6c377a403d9df4b9f745b4cab2794e&
You will of course need to pass the editorState, entityResource and contentResource into your angular controller. And the reason I say it might not be the perfect answer is I believe some of these resources might "touch" the DB so their could be performance constraints
4 Views