在我的应用程序中,页脚在事件加载之前已加载。这些是我尝试过的代码。我在开始时有一个变量设置为false,后来从api加载事件数据时,我将其设置为true。
现在在我的页脚组件中,我设置了ngIf进行检查。
如果我有* ngIf =“ loaded”,则不会显示页脚,并且如果* ngIf =“!loaded”页脚在事件开始前已加载。
有人可以帮助我解决此问题吗?
export class EventsComponent implements OnInit {
events = [];
loaded = false;
constructor(private _eventService: EventService) { }
ngOnInit() {
this._eventService.getEvents()
.subscribe(
res => {
this.events = res;
this.loaded = true;
console.log(this.loaded);
},
err => console.log(err)
);
}
}
<div class="wrapper" *ngIf="loaded">