Здравствуйте дорогие профи!
В вебе я совсем недавно, работаю с Angularfire2, возникла проблема при выводе статуса человека который зашел, как это все происходит, при заходе, запоминается emeil того кто вошел, скрипт находит этот емеил в базе и смотрит на его статус, по умолчанию user, он берет значение status и выводит его {{ item.status }} все просто.
Но почему-то я не могу выполнить скрипт сразу же как вошел человек, ему обязательно нужно нажать на кнопку что бы выполнить тот же скрипт...
Вот как работает:

Вот как не работает, но надо:

Полный код:
import { Component } from '@angular/core';
import { AngularFire, AuthProviders, AuthMethods, FirebaseListObservable } from 'angularfire2';
import { Subject } from 'rxjs/Subject';
@Component({
selector: 'app-root',
template: `
<div *ngIf='tester == false'>
<input type="text" class="form-control" #email placeholder="Введите emeil" />
<input type="text" class="form-control" #password placeholder="Введите пароль " />
<button (click)="register(email.value,password.value)">Регистрация</button>
<hr>
<input type="text" class="form-control" #emais placeholder="Введите emeil" />
<input type="text" class="form-control" #passwords placeholder="Введите пароль " />
<button (click)="login(emais.value,passwords.value)">Войти</button>
<hr>
<button (click)='logOut()'>Покеда</button>
</div>
<div *ngIf='tester == true'>
<button (click)="filterBys('ttt@ttt.com')">user</button>
<p>Status:</p>
<ul>
<li *ngFor="let item of items | async">
{{ item.status }}
<p>...</p>
</li>
</ul>
</div>
`,
})
export class AppComponent {
items: FirebaseListObservable<any>;
emailSubject: Subject<any>;
constructor(public af: AngularFire) {
this.emailSubject = new Subject();
this.items = af.database.list('/users', {
query: {
orderByChild: 'email',
equalTo: this.emailSubject
}
});
this.af.auth.subscribe(auth => console.log(auth));
}
logOut() {
this.af.auth.logout();
}
overrideLogin() {
this.af.auth.login({
provider: AuthProviders.Anonymous,
method: AuthMethods.Anonymous,
});
}
filterBy(email: string) {
console.log('Поиск...');
this.emailSubject.next(email);
console.log('Готово!');
//
}
login(email: string, password: string){
this.af.auth.login({ email: email, password: password }).then((success) => {
this.items.push({ email: email, password: password, status: 'user'});
console.log("Идеальный вход!");
this.filterBy(email); //<------ Функция с которой проблема
this.tester = true;
})
}
register(email: string, password: string){
this.af.auth.createUser({
email : email, password : password
}).then(data=>{
console.log('data',data);
if(data.auth.email === email ){
console.log('Аккаунт успешно зарегистрирован!');
}
});
}
tester = false;
}