Angular7,相关性字段和表达式在检查后已更改

时间:2019-05-22 10:33:16

标签: javascript angular

我有3个相互依赖的选择

<div class="form-group">
    <label for="profession">Profession</label>
    <select
    #professionsSelect
    (change)="professionChanged()"
    [(ngModel)]="job['profession_id']"
    autofocus
    class="form-control"
    id="profession"
    required
    tabindex="10"
    name="profession_id"
    >
    <option value=""></option>
    <option
        *ngFor="let profession of options['professions']"
        value="{{profession.id}}"
    >{{profession.profession}}</option>
    </select>
</div>

<div class="form-group">
    <label for="specialism">Division</label>
    <select
    #specialismSelect
    [(ngModel)]="job['specialism_id']"
    class="form-control"
    id="specialism"
    required
    tabindex="20"
    name="specialism_id"
    >
    <option value=""></option>
    <option
        *ngFor="let specialism of getSpecialisms(professionsSelect)"
        value="{{specialism.id}}"
    >{{specialism.specialism}}</option>
    </select>
</div>

<div class="form-group">
    <label for="sub-specialism">Role</label>
    <select
    [(ngModel)]="job['sub_specialism_id']"
    class="form-control"
    id="sub-specialism"
    required
    tabindex="30"
    name="sub_specialism_id"
    >
    <option value=""></option>
    <option
        *ngFor="let sub of getSubSpecialism(specialismSelect)"
        value="{{sub.id}}"
    >{{sub.subSpecialism}}</option>
    </select>
</div>

最后一个getSubSpecialism触发错误expression has changed after it was checked,我研究了如何解决此错误,但是可以应用我学到的知识this 有没有一种方法可以一次性执行getSpecialismsgetSubSpecialism或禁用渲染一段时间?我相信我不会触发expression ...错误

0 个答案:

没有答案