vendredi 20 novembre 2015

how to set mask and pattern in dynamic fields in AngularJS?

I'm setting the propieties of dynamic fields with Angular, but I have a problem with the mask and the pattern because is null for some fields.

<md-input-container ng-repeat="field in dynamicFields" md-no-float class="md-block m-l-16">
<input name="{{field.name}}" ng-model="consumer[field.name]" placeholder="{{field.text}}" mask="{{field.mask}}" requiered="{{field.required}}" ng-change="textChanged()" />
</md-input-container>

The other fields name, model, placeholder, and required works perfect but mask and pattern don't work because some fields have null value.

This is the controller that populate the fields

for (var item in fields) {
    $scope.dynamicFields.push({
    text: fields[item].description,
    type: fields[item].type,
    pattern: fields[item].pattern || null,
    required: required.indexOf(item) >= 0,
    mask: maskedFields[item] || null,
    name: item
});

This is the error: "TypeError: Cannot read property 'then' of undefined".

Any suggestions? thanks btw!!

Aucun commentaire:

Enregistrer un commentaire