Home Angularjs - radio button show weird action inside of ng-repeat
Reply: 0

Angularjs - radio button show weird action inside of ng-repeat

user1641 Published in May 20, 2018, 3:40 pm

I have an array which has objects, comes from server.

And I have to make list with this array.

I want to set default value to each radio button,

but only the last item has default value.

Please see my code.

    <div id="{{product.product_id}}" class="item-box" ng-repeat="product in cartProducts track by $index">
        <div class="radio-box">
            <input type="radio" name="send_num" ng-checked="product.isBasicNum" ng-click="product.isBasicNum=true"> NumType A
            <input type="radio" name="send_num" ng-checked="!product.isBasicNum" ng-click="product.isBasicNum=false"> NumType B
        <div class="radio-box">
            <input type="radio" name="send_res" ng-checked="product.isImmediateSend" ng-click="product.isImmediateSend=true"> SendType A
            <input type="radio" name="send_res" ng-checked="!product.isImmediateSend" ng-click="product.isImmediateSend=false"> SendType B
        <div class="radio-box">
            <input type="radio" name="receive" ng-checked="product.isRecieveDupable" ng-click="product.isRecieveDupable=true"> ReceiveType A
            <input type="radio" name="receive" ng-checked="!product.isRecieveDupable" ng-click="product.isRecieveDupable=false"> ReceiveType B

and this is fiddle.

What did I miss?

I've tried to find answer, but I could not find similar with mine.

How to set default value to all items?

Thanks in advance.

You need to login account before you can post.

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

© 2016 Powered by mzan.com design MATCHINFO