src/app/sending-money/change-account/change-account.component.ts
| selector | app-change-account | 
            
| styleUrls | change-account.component.css | 
            
| templateUrl | ./change-account.component.html | 
            
                        Properties | 
                
                        Methods | 
                
                        Inputs | 
                
                        Outputs | 
                
    constructor(app: AppState)
                         | 
                    ||||||
| 
                                 
                                        Parameters :
                                         
                        
  | 
                    
                            
                            template
                         | 
                        
                               
                                Type:      | 
                    
                            
                            closeChangeAccount
                         | 
                        
                            $event type:    EventEmitter
                         | 
                    
                            
                            setAndCloseAccount
                         | 
                        
                            $event type:    EventEmitter
                         | 
                    
| isAccountsValid | 
    isAccountsValid()
                         | 
                    
| 
    
                                 
                                    Returns :      
                        boolean
    
                                 | 
                    
| isIdValid | 
    isIdValid()
                         | 
                    
| 
    
                                 
                                    Returns :      
                        boolean
    
                                 | 
                    
| ngOnChanges | ||||||
    ngOnChanges(changes: SimpleChanges)
                         | 
                    ||||||
| 
    
                                 
                                        Parameters :
                                         
                                
 
                                    Returns :      
                                    void
    
                                 | 
                    
| ngOnInit | 
    ngOnInit()
                         | 
                    
| 
    
                                 
                                    Returns :      
                        void
    
                                 | 
                    
| setDefaultAccount | ||||||
    setDefaultAccount(account: BankAccount)
                         | 
                    ||||||
| 
    
                                 
                                        Parameters :
                                         
                                
 
                                    Returns :      
                                    void
    
                                 | 
                    
| stopPropagation | ||||||
    stopPropagation(event: Event)
                         | 
                    ||||||
| 
    
                                 
                                        Parameters :
                                         
                                
 
                                    Returns :      
                                    void
    
                                 | 
                    
| toggleChangeAccount | ||||||
    toggleChangeAccount(event: Event)
                         | 
                    ||||||
| 
    
                                 
                                        Parameters :
                                         
                                
 
                                    Returns :      
                                    void
    
                                 | 
                    
| accounts | 
                            accounts:     
                         | 
                    
                                Type :     BankAccount[]
    
                             | 
                        
| session | 
                            session:     
                         | 
                    
                                Type :     Session
    
                             | 
                        
import {
  Component,
  EventEmitter,
  Input,
  OnChanges,
  OnInit,
  Output,
  SimpleChanges
} from '@angular/core';
import { BankAccount, Session, Template } from '../../models';
import { TemplateService } from '../../services';
import { AuthService } from '../../services/auth.service';
import { SessionStore } from '../../stores';
import { AppState } from '../../stores/app-state.store';
import { filter, map } from 'rxjs/operators';
@Component({
  selector: 'app-change-account',
  templateUrl: './change-account.component.html',
  styleUrls: ['./change-account.component.css']
})
export class ChangeAccountComponent implements OnInit, OnChanges {
  @Output()
  closeChangeAccount = new EventEmitter();
  @Output()
  setAndCloseAccount = new EventEmitter();
  @Input()
  template: Template;
  session: Session;
  accounts: BankAccount[];
  constructor(private app: AppState) {}
  ngOnInit() {
    this.app.state$.pipe(filter(state => state !== null)).subscribe(state => {
      this.accounts = state.accounts;
    });
  }
  ngOnChanges(changes: SimpleChanges) {
    if (changes['template'] && this.isIdValid() && this.isAccountsValid()) {
      const matched = this.accounts.filter(a => a.id === this.template.payFromBankAccount.id);
      if (matched.length > 0) {
        this.setDefaultAccount(matched[0]);
      }
    }
  }
  isAccountsValid() {
    return this.accounts !== null && this.accounts !== undefined && this.accounts.length > 0;
  }
  isIdValid(): boolean {
    return this.template !== undefined && this.template !== null;
  }
  toggleChangeAccount(event: Event) {
    this.closeChangeAccount.emit();
  }
  stopPropagation(event: Event) {
    event.stopPropagation();
  }
  setDefaultAccount(account: BankAccount) {
    this.setAndCloseAccount.emit(account);
  }
}
    <div class="overlay scroller" id="changeAccountPopup" (click)="toggleChangeAccount($event)">
  <div class="pop-up-ctn" id="changeAccount">
    <div class="close-ctn" (click)="stopPropagation($event)">
      <a id="closeButton" (click)="toggleChangeAccount($event)">
        <i class="material-icons">close</i>
      </a>
    </div>
    <div class="pop-up-ctn-header" (click)="stopPropagation($event)">
      <p class="header-text">Change Account</p>
    </div>
    <div class="pop-up-ctn-body" (click)="stopPropagation($event)">
      <label *ngFor="let account of accounts" (click)="setDefaultAccount(account)">
        <div class="switch-accounts">
          <app-account-label [account]="account"></app-account-label>
          <input type="radio" name="default-checking-account" value="">
          <span class="custom-radio"> </span>
        </div>
      </label>
    </div>
  </div>
</div>