Reputation: 88
I have a row based template and i need to display a calculation result within my form. the value is stored in the view model variable calc.
simple html element approach didnt work,
{
key: 'html',
template: '<div>' +
'Hello the value is {{vm.calc}}' +
'</div>'
}
any tips?
Upvotes: 1
Views: 885
Reputation: 520
Create a type similar to
formlyConfigProvider.setType({
name: 'calculationResult',
template: "<div>Hello the value is {{to.calc}}</div>",
wrapper: ['bootstrapLabel']
});
then add this as a field to your form
{
key: 'taskList',
type: 'calculationResult',
templateOptions: {
label: 'Calculation Result',
calc: ''
},
controller: function ($scope) {
$scope.to.calc = $scope.model.c * $scope.model.b;
}
}
I don't see any other better way to make the calculation display as a normal field value.
Upvotes: 1