We are using angluar-formly forms to make our forms. However when a user inputs an invalid input we would like for them to have a clear error message. So I have created a validator using expression: and message: however I cannot get the message to show up.
The controllers fields value contains:
{
key: 'port',
defaultValue: 2301,
type: 'input',
validators: {
isPort: {
expression : function(viewValue, modelValue) {
var value = modelValue || viewValue;
return !value || (/^\d+$/.test(value) && value!='' && value>0 && value<65535);
},
message: '$viewValue +" is not a valid port"'
}
},
templateOptions: {
type: 'number',
required: true,
label: 'Port',
placeholder: 'Enter Port'
}
}
and we call on the fields in our html code:
<formly-form model="execServers" fields="informationFields" form="form2"></formly-form>
However we do not see the error message show up. It does go to red and show invalid just no message.
I have also created a jsbin depicting my problem http://jsbin.com/weyotudoqu/1/edit?html,js,console,output
I am pretty sure I am just missing something simple as I have looked at lots of examples which do this exact thing and have the text show up http://angular-formly.com/#/example/intro/codementor