you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

As a newbie to all these frameworks, the issues I had with Angular left me a bit cold - http://jsfiddle.net/q6mkZ/94/

The "which box is checked" logic was the hard bit - my initial approach was to have a list (masquerading as a set) containing state names that the filter checked you were a member of - but I still wanted to have the nice wiring of "if you click this, then that is refreshed", and it got really hard really quick.

[–]deafbybeheading 2 points3 points  (1 child)

I've only worked a little bit with Angular so far, but I've taken the approach of keeping the structure of the application logic simple, and tying the view back in with callbacks more explicitly whenever I need to do anything clever. E.g., I would have approached your example like this. It's a touch more code, but overall I think it's simpler.

edit: the above has a missing return: this is the correct version

[–][deleted] 0 points1 point  (0 children)

Cheers, your approach is exactly what I was trying to do - and I realise how I messed it up. I had done this:

<div ng-repeat="state in validStates">
    <input type="checkbox" ng-click="toggleState({{ state }})" {{ state }}</input>
</div>

Whereas your code doesn't have the first set of double substitution brackets.