次のように単純なコンポーネントをセットアップしました。
import { Component, OnInit } from '@angular/core';
import { Meteor } from 'meteor/meteor';
import { InjectUser } from 'angular2-meteor-accounts-ui';
@Component({
selector: 'my-component',
template: 'Hello, World!'
})
@InjectUser('user')
export class myComponent implements OnInit {
user: Meteor.User;
ngOnInit() {
console.log(this.user); // undefined
}
}
this.user
ログインしたユーザーの情報が含まれていると思います。ロードされた後続のすべてのコンポーネントで機能しますが、ロードされた最初のコンポーネントthis.user
はundefined
コンポーネントが初期化される前に、ユーザーデータが事前に入力されるようにしたいと思います。そうすれば、すべてのコンポーネントで同じサブスクリプション コードを使用する必要がなくなります。どうすればいいですか?