It seems there's an issue with the ngChange function of md-radio-button.
Using the following code, the changeNeed function is never called when the user select one of the radios:
<md-radio-group>
<md-radio-button ng-model="advertisement.need" ng-change="changeNeed(need)" ng-repeat="need in needs" name="need" ng-required="true" ng-value="need">
{{'DOMAIN_ENUM_NEED_DESCRIPTION_' + need | translate}}
</md-radio-button>
</md-radio-group>
I have tried moving the
ng-model="advertisement.need" ng-change="changeNeed(need)"
attributes into the md-radio-group but then of course the ng-repeat item (here need) is no longer available...
Is there a way to circumvent this issue?
@balteo
First of all, ng-model and ng-change are only allowed on md-radio-group element.
You have two options to get desired behavior:
ng-click="changeNeed(need)" on md-radio-buttonng-change="onChangeNeed()" on md-radio-group and implement it like this:$scope.onChangeNeed = function() {
var updatedNeed = $scope.advertisement.need;
// Do something with the new value of advertisement.need
};
@sazonenka : thanks!
Documentation is incorrect. ngChange is listed as belonging to md-radio-button: https://material.angularjs.org/latest/api/directive/mdRadioButton
Documentation is still incorrect. Is not possible to use ngChange on a md-radio-button but only ngClick https://material.angularjs.org/latest/api/directive/mdRadioButton
Most helpful comment
Documentation is still incorrect. Is not possible to use ngChange on a md-radio-button but only ngClick https://material.angularjs.org/latest/api/directive/mdRadioButton