0

I am not able to get value from radio buttons in reactive form. It always come empty string. How could I solve that? Below is the code for that:

<form (ngSubmit)="onSubmit(segment_abc)" [formGroup]="segment_abc">
<div class="container">
    <div class="row product-chooser">
        <div class="col-md-4 col-sm-6 selected product-chooser-item" id="div1" tabindex="-1">
            <div class="pricingTable">

                            <i class="fa fa-rupee"> 400</i><span class="gst"> + GST</span>
                            <input type="radio" formControlName="segment123" [value]=1>
                            <!-- <a href="#" class="pricingTable-signup">Subscribe Now</a> -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4 col-sm-6  product-chooser-item" id="div2" tabindex="-1">
            <div class="pricingTable">


                    <div class="bottom">
                        <div class="txt_400">
                            <i class="fa fa-rupee"> 1000</i><span class="gst"> + GST</span>
                            <input type="radio" formControlName="segment123" [value]=2>
                            <!-- <a href="#" class="pricingTable-signup">Subscribe Now</a> -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-md-4 col-sm-6  product-chooser-item" id="div3" tabindex="-1">
            <div class="pricingTable pricingTablepremium">

                            <input type="radio" formControlName="segment123" [value]=3 (click)="openValue()">
                            <!-- <a href="#" class="pricingTable-signup">Subscribe Now</a> -->
                        </div>
                    </div>
                </div>
            </div>
        </div>

    </div>

    </div>
    <!-- <button type="submit" class="btn btn_form" (click)="open(content,'email')">Submit</button> -->
    <button type="submit" class="btn btn_form" >Submit</button>
</div>

There is no output in when I am getting values in form control

5
  • First of all, I do not see any Reactive form used in the stackblitz shared by you. Secondly, your section list contains checkboxes, that means one can select multiple, you should make them radio buttons to have only one selected or you can define a checkbox group having checkboxes with same name attribute ( this will help in getting only one selected). Let me know if this is what you wanted Commented Nov 19, 2018 at 1:47
  • @nkuma_12 That's radio buttons, I have updated issue and code as well. You can check now. Commented Dec 5, 2018 at 7:38
  • take a look here for details: stackoverflow.com/a/46720577/9386929 Commented Dec 5, 2018 at 12:59
  • I have already gone through same code and that is not working for me that's why I put this question. Commented Dec 6, 2018 at 4:33
  • can you put up a stackblitz link with your component and mocked accounts data? Commented Dec 6, 2018 at 13:54

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.