Home ng-repeat with radio button toggle on a specific condition
Reply: 0

ng-repeat with radio button toggle on a specific condition

user1074
1#
user1074 Published in April 25, 2018, 7:40 pm

I have a couple radio button toggles generated by ng-repeat. By default, I would like the first radio buttons all toggled, and if a conditional applies, I would like only that radio button toggled.

<li ng-repeat="method in itemGroup.ShippingMethods">
    <input ng-model="itemGroup.SelectedShippingMethod" 
           ng-change="changeShipping(itemGroupKey, 
           itemGroup.SelectedShippingMethod)" 
           type="radio" 
           name="Shipping" 
           id="method.Name" 
           value="method.Name" 
    />

In my JS file:

$scope.itemGroup = { SelectedShippingMethod: "Express" };

The intention of the code is to have the first button toggled by default, unless the condition is hit (Express Shipping), in which that button would be toggled.

In a list of [Standard, Fast, Speedy], Standard radio button would be toggled. In a list of [Standard, Fast, Express], Express radio button would be toggled.

Any help would be greatly appreciated.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.312149 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO