samedi 21 février 2015

Multiple Checkboxes in Angular

I'm new to Angular so sorry if any of the terminology is wrong.


I'd like to have multiple text input boxes, and when a user types into those boxes it outputs that on the screen. If they then click 1 checkbox it will wrap what they have typed in some text (in this case the text is onclick="...").


If they check the second checkbox it should wrap the output in something else (e.g. SomethingElse="...").


My problem is the 1st checkbox seems to be bound to the second checkbox, I think I need to use different scopes, but I can't get my head around this.


Currently using ng-switch-when and trying to set the values in the controller, but it's failing to bind separately as per plunker here: http://ift.tt/1B2Gjgc



<div class="code alert-box warning" ng-switch on="TrackingCode.AddOnClick">
<div ng-switch-when="true">
<!-- code to render when AddOnClick checkbox is checked-->
<code>
onclick="_gaq.push(['_trackEvent({{category}}', '{{action}}', '{{label}}', '{{value}}', '{{nonInteraction}}']);"
</code>
</div>
<div ng-switch-when="test">
<!-- code to render when Something Else checkbox is checked-->
<code>
SomethingElse="_gaq.push(['_trackEvent({{category}}', '{{action}}', '{{label}}', '{{value}}', '{{nonInteraction}}']);"
</code>
</div>
<div ng-switch-default>
<!-- code to render when AddOnClick checkbox is un-checked -->
<code>
_gaq.push(['_trackEvent', '{{category}}', '{{action}}', '{{label}}', '{{value}}', '{{nonInteraction}}']);
</code>
</div>
</div>




Aucun commentaire:

Enregistrer un commentaire