【问题标题】:FormControl valueChanges not firingFormControl valueChanges 未触发
【发布时间】:2020-10-21 15:40:09
【问题描述】:

这段代码可能有什么问题?我看不到 valueChanges 被解雇了。

ngOnInit() {
    this.tagsSubscription = this.service.tags$.subscribe(...);
    this.createForm();
    this.service.getSupportedTags(new TagId('sometag')); 
    this.languageSelectorForm.get('tagsFilterCtrl').valueChanges
      .pipe(takeUntil(this._onDestroy))
      .subscribe(() => {
        console.log("received value chnage from filter control ");// I don't see the print and the mat-select object's value is `object Object`
        this.filterTags();
      });
  }


createForm() {
    this.languageSelectorForm = this.fb.group({
      tags: [null, Validators.required],
      tagsFilterCtrl:[null] //filter input shows here
    });
  }

过滤器控件被用作

<div id="mat-select-div">
          <mat-select id="language-selector" placeholder="Tags" class="selectpicker" formControlName="tags" [ngClass]="validateField(languageSelectorForm,'tags')" #singleSelect>

            <mat-option *ngIf="newSearch">Please select</mat-option> 
            <mat-option>
              <ngx-mat-select-search formControlName="tagsFilterCtrl"></ngx-mat-select-search>
            </mat-option>
            <mat-option *ngFor="let tag of filteredTags | async" [value]="tag">{{tag.subject}}</mat-option>
          </mat-select>
        </div>

【问题讨论】:

    标签: angular6


    【解决方案1】:

    问题不在于valuechanges。还有其他一些逻辑错误。但是,奇怪的是我在 valueChanges observable 中没有看到打印。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-02-10
      • 2017-09-18
      • 2019-01-25
      • 1970-01-01
      • 2017-11-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多