Parse JSON

I have a channel that provides json (as a raw string). I can’t for the life of me figure out how to parse the JSON in a template where it’s usable by angular functions.

Basically I have a channel that returns "[{id:1,name:'stuff'},{id:2,name:'stuff2'}]". What I’d like to do is something like "<li ng-repeat="x in itemValue('jsonChannel')"

Would be great if there was a json parse function in the controller (or a itemValueAsJson function)…

Tim

Angular’s scopes have an $eval method which can do that :slight_smile:

This has actually been brought up before:

Cheers!

Thanks alot - still new to angularjs but I’ve already put together a fairly complex custom template that I’ll post shortly.

BTW - have you ever considered somehow integrating custom templates with binding? In other words, it would be great to include any custom template (and resources like icons, etc) with the binding itself and have those templates/resources discoverable by habpanel. Example: I created the Russound (multiroom music controller) binding and am putting together a player custom widget for it - I’d love to have it distributed and made available to anyone that installs the binding itself…

BTW2 - am I right in assuming I can’t create controller methods? I have some code (that parses channel ids) that I am using over and over - I’d love to define a controller method for it and simplify the template…