I was working on a settings page and wanted to change the selected radio based on some variables that stored in the localStorage, but it seems that ng-checked does not work
Here’s the code
I was working on a settings page and wanted to change the selected radio based on some variables that stored in the localStorage, but it seems that ng-checked does not work
Here’s the code
Any updates guys?! …
i am running in to same issue. @m_abdelfattah did you ever figure out how to fix this?
Use ng-change as per the Angular docs:
https://docs.angularjs.org/api/ng/input/input[radio]
<input type="radio"
ng-model="string"
value=“string”
[name=“string”]
[ng-change=“string”]
ng-value=“string”>
Hi guys, I know it’s an old topic but I ran to the same problem today. Using Ionic, v1.2.4.
I found that the reason why ng-checked doesn’t work with <ion-radio></ion-radio>
is because in the Ionic lib, a the ionRadio
directive, the attribute ng-checked
is not loaded by default.
You can make it work by just adding it to your ionic-angular.js file.
Find .directive('ionRadio', function()
in your ionic-angular.js file and change this forEach
to add the ng-checked
attribute, at line 12169:
var input = element.find('input');
forEach({
'name': attr.name,
'value': attr.value,
'disabled': attr.disabled,
'ng-value': attr.ngValue,
'ng-checked': attr.ngChecked, //ADD THIS LINE
'ng-model': attr.ngModel,
'ng-disabled': attr.ngDisabled,
'ng-change': attr.ngChange,
'ng-required': attr.ngRequired,
'required': attr.required
}, function(value, name) {
if (isDefined(value)) {
input.attr(name, value);
}
});