Angular Dev question - ngOnChanges() method

Viewed 39

Got this code on the ngOnChanges block. I'm struggling to get it to execute the last if-statement after the firstChange. I could use some help folks!

ngOnChanges(changes: SimpleChanges) {debugger
  const banker = this.store.selectSnapshot(InternalUserState.getInternalUser);
  if (changes.teamBankers && changes.teamBankers.firstChange) {
    if (
      changes.allocationFromBanker &&
      changes.allocationFromBanker.firstChange
    ) {
      this.currentBanker$.subscribe( (result: InternalUser) => {
        this.currentUser = result.username;
      });
      this.teamBankers = this.teamBankers.filter(
        (x) => x.username !== this.allocationFromBanker.username
      );
    }
    this.getBankersByConversationState();
  }
  if (
    changes.allocationFromBanker &&
    !changes.allocationFromBanker.firstChange &&
    changes.allocationFromBanker.currentValue == null
  ) {
    this.teamBankers.push(changes.allocationFromBanker.previousValue);
    this.getBankersByConversationState();
  }
}
0 Answers
Related