Are you trying to read the value of a parameter that has been set on your macro ?
If so you can read the value of a parameter set on a macro in razor like so:
var parameterValue = Model.GetParameterValue
(setting isParameterEditor allows you to use the property editor as a macro parameter type)
or
Are you just trying to read the value of a property on the document type as you loop through a selection of nodes ? (and the property is a custom editor that stores complex values as Json ?)
In this case (isParameterEditor is irrelevant), you would need to first retrieve the value of the property, and then deserialise the Json to be able to access the values saved on the angular model.
eg I think something like this would work:
var JsonPropertyData = item.propertyAlias;
dynamic propertyData = Json.Decode(jsonPropertyData);
you can see I've created a dynamic variable called 'jsonContent' and used Json.Decode to parse the blob of Json for the content property into a dynamic object.
now instead of writing out the blog of json with @post.content, I can instead use @jsonContent.name or write out any of the properties in the json blog using the dynamic syntax, with the result...
I tried your code but couldn't make it work. Could you point me to the part of the documentation about this issue? As I couldn't find it by myself.
I'm trying to display a custom html table in the backoffice that will be rendered with its css within a macro as a product. But I'm not sure if I'm taking the right approach.
How can I access the value of an AngularJS model within a macro?
I tried to set
isParameterEditor
totrue
in thepackage.manifest
and access it like this:But keep receiving an "Error loading Partial View script".
Any ideias of what I've been doing wrong?
Hi Vinicius
Are you trying to read the value of a parameter that has been set on your macro ?
If so you can read the value of a parameter set on a macro in razor like so:
var parameterValue = Model.GetParameterValue
(setting isParameterEditor allows you to use the property editor as a macro parameter type)
or
Are you just trying to read the value of a property on the document type as you loop through a selection of nodes ? (and the property is a custom editor that stores complex values as Json ?)
In this case (isParameterEditor is irrelevant), you would need to first retrieve the value of the property, and then deserialise the Json to be able to access the values saved on the angular model.
eg I think something like this would work:
var JsonPropertyData = item.propertyAlias; dynamic propertyData = Json.Decode(jsonPropertyData);
@propertyData.NameOfTheModelOne
Hi, Marc! Thanks for taking the time to reply. I think that my case would be the second one. But I tried your code and couldn't solve my problem.
Do you have any other idea?
I'll try to explain it better: It is a custom property editor that I'm trying to retrieve its values.
Hi Vinicius
Ok, then the first thing to confirm is currently what is the value of:
@item.propertyAlias
for your custom property when you loop through
is it a JSON object ?
regards
Marc
Would you mind to explain me how can I get the property type?
When you added your custom property to your document type, what alias did you give it ?
and what do you see if you just write the property out ?
So for example in the Fanoe Starter kit the blog overview template loops through each blog post to give a teaser for each post:
However the property 'content' is one I've added here under the h2 element, it's a grid property and so it's value is stored as Json
By writing it out here in the template, I can see what value has been stored in Umbraco for the property:
and it comes out a bit like this:
eg the bits in red - lots of Json !!!
So now if we try the Json.Decode trick
you can see I've created a dynamic variable called 'jsonContent' and used Json.Decode to parse the blob of Json for the content property into a dynamic object.
now instead of writing out the blog of json with @post.content, I can instead use @jsonContent.name or write out any of the properties in the json blog using the dynamic syntax, with the result...
I tried your code but couldn't make it work. Could you point me to the part of the documentation about this issue? As I couldn't find it by myself.
I'm trying to display a custom html table in the backoffice that will be rendered with its css within a macro as a product. But I'm not sure if I'm taking the right approach.
is working on a reply...