Hi there guys i fetch form my Laravel backend a object with some devices associated to logged user. I store the data into my Ionic localstorage in this way:
login(user: User): Observable<AuthResponse> {
return this.http.post(`${this.apiURL}/login`, user).pipe(
tap(async (res: AuthResponse) => {
console.log('res', res);
await this.storage.set("ACCESS_TOKEN", res['data']['token']);
await this.storage.set("id", res['data']['id']);
await this.storage.set("devices", res['data']['devices']);
console.log(this.authSubject);
this.authSubject.next(true);
})
);
}
SO now i need to create a ion-slides foreach devices that i fetch after login. I tried in my NgInit:
ngOnInit() {
this.storage.get("devices").then((value) =>
{
console.log('devices', value);
let devices = value;
});
}
but didn't work. I need to show devices as slideshow in my view:
<ion-slides >
<ion-slide *ngFor="let device of this.devices">
<ion-row>
<h1>{{ device.name }}</h1>
</ion-row>
<ion-row>
<img src="{{ device.image }}" >
</ion-row>
</ion-slide>
1条答案
按热度按时间wsewodh21#
在那里,您应该将
devices
绑定到组件类的this
上下文,而不是在let
变量中至
在HTML中,尽管使用
this.devices
,但仍使用devices