Given the need to extract data from a viewdata into a javascript key/value object:
var stuff = {
something : [@someVar.Prop2, @someVar.Prop3, etc]
};
I want to make the key have the "name" of someVar.Prop1 so that:
var stuff = {
@someVar.Prop1 : [@someVar.Prop2, @someVar.Prop3, etc]
};
Yet when I use the form in the second code block above, I get a Expected identifier, string or number error at the colon:
@someVar.Prop1 : [@someVar.Prop2, etc]
---------------X (x marks the spot)
How do I need to format the razor code so that it knows what I'm trying to say?
's, parsing the values you need if necessary. Ex:var stuff = { something : [ '@myVal', parseInt('@myVal2') ] }