1

I am trying to get radio button checked or un checked based on flag status, though it is alsways checked for first radio button ffor below code

<label class="col-md-5 control-label">Active?</label>
    <div class="col-md-6">
        <label class="radio-inline">
            <input type="radio" name="activeFlag" id="active" value="active" ng-checked="{{flag}}"> True
        </label>
        <label class="radio-inline">
            <input type="radio" name="activeFlag" id="deactive" value="deactive" ng-checked="{{!flag}}"> False
        </label>
    </div>

Here flag can be false or true based on input value. "Inspect Element" shows as below:

                  <div class="col-md-6">
                        <label class="radio-inline">
                            <input type="radio" name="activeFlag" id="active" value="active" ng-checked="true" checked="checked"> True
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="activeFlag" id="deactive" value="deactive" ng-checked="false"> False
                        </label>
                    </div>

I dont have idea from where that checked attribute pops up . Please help.

1 Answer 1

2

ngChecked expects an Angular expression - so remove the {{}}

ng-checked="!flag"
Sign up to request clarification or add additional context in comments.

1 Comment

it worked... thanks... though i cant understand why it was adding checked attribute all by itself, also it was giving corrent output for ng-checked as well, so it never occured to me that i need to remove {{}}.

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.