ng-checked is not working in the application as its working for check box without any effect ,I am facing issue for radio button
<input type="radio" class="radio" name="job_class_radio" ng-checked="key===jobClassData.selectedOption" ng-click=changeJobClass(value)>
I am seeing this in browser inspected element
<input type="radio" class="radio" name="job_class_radio" ng-checked="key===jobClassData.selectedOption" ng-click="changeJobClass(value)" checked="checked">
we can see checked="checked" is adding after compilation
Update:
<label class="radio" ng-if="key!='selectedOption'" ng-repeat="(key,value) in jobClassData track by $index">
<input type="radio" class="radio" name="job_class_radio" ng-checked="jobClassData.selectedOption===key" ng-value="key" ng-click=changeJobClass(value)>
<span class="radio"></span>
<span ng-bind="key"></span>
</label>
JSON:
{
"selectedOption": "Unit Category",
"Job Class": [
{},
{}
],
"Unit Category": [
{},
{},
{}
]
}
I want to select attribute based on selectedOption key
If you want radio button to be default checked, it should have 'value' and 'ng-model' attributes.
<input type="radio" class="radio" name="job_class_radio" ng-model="jobClassData.selectedOption" value="option1">
And in controller:
$scope.jobClassData = {
selectedOption: 'option1'
}
You can read more about it here: https://docs.angularjs.org/api/ng/input/input%5Bradio%5D
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.