Skip to content Skip to sidebar Skip to footer

Angularjs Validation And Field Name With Square Brackets

I'm following this tutorial http://scotch.io/tutorials/javascript/angularjs-form-validation but I have form fields with square brackets ( for example company_bundle_task[timeStart]

Solution 1:

You have to escape your name in quotes, since a.example is equivalent of a['example'] you can write:

<span class="help-block" ng-show="company_bundle_task['company_bundle_task[timeStart][date]'].$error.required">Required</span>

Solution 2:

Mati, You should try and use a function rather than evaluating such a long expression... call a simple function which is attached to your scope and controller and evaluate this expression correctly in it....

I usually, do not try to write the expression there but functions...

Regards

Post a Comment for "Angularjs Validation And Field Name With Square Brackets"