V
V
Vassa2014-06-01 19:24:22
Angular
Vassa, 2014-06-01 19:24:22

How to deal with hard to read HTML when using angularJS?

Actually, subject, the code becomes hard to read, what to do about it?
Code example:

<input class="d-form__input-text" name="pickup__point_address" ng-model="pickup__point_address" ng-required="true" ng-focus="focusHandler($event)" ng-blur="blurHandler($event)">
<div class="d-form__error" ng-show="orderingForm.pickup__point_address.$invalid && orderingForm.pickup__point_address.$dirty"><span class="d-form__exlmark"></span> Пожалуйста, заполните поле</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2014-06-01
@Mr_Pukin

<input class="d-form__input-text" 
           name="pickup__point_address" 
           ng-model="pickup__point_address"
           ng-required="true"
           ng-focus="focusHandler($event)" 
           ng-blur="blurHandler($event)">

<div class="d-form__error"
        ng-show="orderingForm.pickup__point_address.$invalid && orderingForm.pickup__point_address.$dirty">
     <span class="d-form__exlmark"></span> Пожалуйста заполните поле
</div>

ps span inside d-form_error I would remove and replace with :before to the container class.
Also, the condition in ng-show can be made a little simpler - make your own directive, like show-on-invalid="orderingForm.pickup__point_address" and everything will be a little nicer (I think there are enough such things in your forms.) Well, or something else you can think of something like putting the helper method into the controller (not very good, but possible)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question