After reading quite a few posts I decided that this ought to work:
vm.model.myChange = function(element) {
console.log(element);
}
.. and in the vm.fields:
{
"key": "transportation",
"type": "select",
"templateOptions": {
"label": "How do you get around in the city",
"valueProp": "name",
"onChange": "model.myChange()", // ADDED
"options": [{
"name": "Car"
}, {
"name": "Helicopter"
}]
}
In practice this has no effect, i.e. my function is not called. The generated form contained no reference to my function either.
I could not find a working example of how to do this. Any suggestions?
Thx. Paul
you can do any of these three things:
templateOptions: {
onChange: function($viewValue, $modelValue, $scope) {
//implement logic here
};
}
OR
templateOptions: {
onChange: callMe()
},
controller: function($viewValue, $modelValue, $scope) {
$scope.callMe = function() {
//implement logic here
};
}
OR
templateOptions: {
onChange: ''
},
expressionProperties : {
'templateOptions.onChange': function($viewValue, $modelValue, $scope) {
//implement logic here
};
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With