あなたが急いでいる場合は、このようなものが私のために働く。
import { Component, OnInit } from '@angular/core';
import { Http } from "@angular/http";
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/delay';
@Component({
selector: 'your-selector',
template: `
<div>
<h1 *ngIf="firstLoader">First Loading...</h1>
<h1 *ngIf="secondLoader">Second Loading..</h1>
</div>
`,
styles: []
})
export class YourComponent implements OnInit {
firstLoader: boolean = true;
secondLoader: boolean = false;
constructor(
private _http: Http
) { }
ngOnInit() {
setTimeout(() => {
this.secondLoader = true;
}, 1000); // your second loader interval
this._http.get('https://jsonplaceholder.typicode.com/photos')
.map(res => res.json())
.delay(2000) // add network throttling
.subscribe(res => {
// console.log(res);
this.firstLoader = false;
this.secondLoader = false;
})
}
}
角度アプリとDOMの初期読み込み/ブートストラップにかかる時間、つまり単一のコンポーネントの長さを意味しますか?試したコードの一部を表示する –