简体   繁体   中英

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.

have you tried doing strict comparison operator?

== checks for reference equality

=== for value.

I suspect that is your issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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