title: login authentication in angular
body: <p>I am new to angular and am trying to implement a simple registration and login authentication. I can register easily to push the data to firebase. What I have stuck here is while login if username and password matches then it redirect to another page else redirect throw error.</p>
  
  <p>html:</p>
  
  <pre><code>&lt;form id="submission" [formGroup]="fbform"&gt;
          &lt;div class="form-group"&gt;
          &lt;label for="name"&gt;Name:&lt;/label&gt;
          &lt;input type="text" class="form-control" placeholder="Username" [(ngModel)]="name" formControlName="name"&gt;
          &lt;/div&gt;
          &lt;div class="form-group"&gt;
          &lt;label for="password"&gt;Password:&lt;/label&gt;
          &lt;input type="text" class="form-control" placeholder="Password" [(ngModel)]="password" formControlName="password"&gt;
          &lt;/div&gt;
          &lt;button type="submit" (click)="SignIn(name,password)" class="btn btn-default" [disabled]="!fbform.valid"&gt;Submit&lt;/button&gt;
      &lt;/form&gt;
  </code></pre>
  
  <p>signup-component.ts</p>
  
  <pre><code>SignIn(name,password){
    let username = name;
    let password = password;
    let credentials = btoa(username + '??' + btoa(password)) // 
  
    firebase.database().ref('/users').on('child_added', (data)=&gt;{
        let dat = data.val()
        this.values.push(dat)
        let check = this.values.filter(val =&gt; val.name == username &amp;&amp; val.name == password );
  
        //after that am stucked 
        if (check2 ? 'true':'false'){
          this.router.navigateByUrl('/');}
        }
    )
  }
  </code></pre>