L
L
Leopandro2018-07-22 09:25:05
Angular
Leopandro, 2018-07-22 09:25:05

Why is the select selection left empty?

TS:

ngOnInit() {
        this.route.data
            .subscribe(data => {
                    console.log(data);
                    var params = data['params'];
                    this.car_brands = params['car_brands'];
                    this.car_classes = params['car_classes'];
                    this.taxi_brands = params['taxi_brands'];
                    this.client_types = params['client_types'];
                    this.tariffs = params['group_tariffs'];
                    Object.assign(this.model, data['data']);
                    console.log(data);
                },
                error => {
                    console.log(error['error']);
                    this.errors = error['error'];
                });
    }

HTML:
<div [ngClass]="hasError('number')" class="form-group">
        <label class="col-lg-3 control-label">Номер:</label>
        <div class="col-lg-9">
          <input type="text" class="form-control" [(ngModel)]="model.number" name="number">
          <span *ngIf="errors['number']" class="help-block">{{errors['number'][0]}}</span>
        </div>
      </div>

      <div [ngClass]="hasError('brand_id')" class="form-group">
        <label class="col-lg-3 control-label">Бренд такси:</label>
        <div class="col-lg-9">
          <select name="repeatSelect" id="repeatSelect" class="form-control"  [(ngModel)]="model.brand_id" >
            <option *ngFor="let item of taxi_brands;" [value]="item['id']"> {{item.name}} </option>
          </select>
          <span *ngIf="errors['brand_id']" class="help-block">{{errors['brand_id'][0]}}</span>
        </div>
      </div>

In the TS code, I fill in the array for select, then the model itself, I use a simple one, without formcontrols, then in html the input and radio buttons are filled, and the selection decreases for selects. on other pages everything is ok, but there I use an array of arrays, and here an array of objects, and my selection drops ...

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question