Jester Jester - 10 months ago 65
AngularJS Question

pass object to directive

I would like to do the following:

<my-directive my-object="{Code:'test'}"/>

Then convert the string to an object in the controller.
Currently using JSON.parse

I know I can do this:

<my-directive my-object="{&quot;Code&quot;:&quot;test&quot;}"/>

But seems messy and hard to read

Any way to do this?


It's not pretty, but it is valid to simply do:

<my-directive my-object='{"Code":"test"}'/>