I am using angular-formly
in my application. I defined a field with custom template which returns radio buttons. On selecting a particular radio button ng-click
is not working, call is not coming to my controller function. It would be great if someone helps me to get a solution for this issue.
$ctrl.fields =[{
noFormControl: false,
template: <div>
<input type="radio" ng-model="$ctrl.isPlacementCommon" value="true" onclick="$ctrl.changePlacementDisplay('true')">
<label>Place all VNFs on same resource</label>
<input type="radio" ng-model="$ctrl.isPlacementCommon" value="false" onclick="$ctrl.changePlacementDisplay('false')">
<label>Allow separate placement for VNFs</label>
</div>
}
];
You are looking for the ng-change
directive rather than ng-click
.
ie in your controller
$ctrl.changePlacementDisplay = function(val){
//logic inside your changePlacementDisplay
};
then in your template
<input type="radio" ng-model="$ctrl.isPlacementCommon" value="true" ng-change="$ctrl.changePlacementDisplay(true)">
I took out the quotes around true
. You can leave them if you'd rather passback a string.
If you continue to have issues and the ng-change function is not being called, I would suggest going back to the angular-formly docs. I'm unfamiliar with that library so I can't help there.
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.