简体   繁体   English

当输入获得值 Angular 9 时组件会发生变化

[英]Component changes when input gets value Angular 9

<component1 *ngIf="field != '' " //component 1 should load if value is Not empty
<component2 *ngIf="field == '' " //component 2 should load if value is empty
   <Mat-Select></Mat-select>

when the Select from component number 2 gets a value it changes to component number 1.Im not sure why this would happen because in component2 the value gets assigned to a different variable in another object.当 Select from component number 2 获得一个值时,它会更改为 component number 1。我不确定为什么会发生这种情况,因为在 component2 中,该值被分配给另一个对象中的不同变量。

have you tried doing strict comparison operator?你试过做严格的比较运算符吗?

== checks for reference equality ==检查引用相等

=== for value. ===价值。

I suspect that is your issue.我怀疑这是你的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM