【发布时间】:2020-08-22 09:03:01
【问题描述】:
我正在尝试将存储为可观察的 api 响应的 JSON 响应的属性绑定到离子标题。但无法让它工作。有人可以帮我解决其中的问题吗?
page.ts
export class DisplayPage implements OnInit {
Category : any;
result: Observable<any>;
constructor(private route: ActivatedRoute, private router: Router, private myService: MyService) {
this.Category = this.route.snapshot.params.Category;
var id = this.route.snapshot.params.id;
this.result = this.myService.result(this.Category,id);
this.result.subscribe(res => console.log(res.name));//can see the response here logged
}
page.html
<ion-header>
<ion-toolbar>
<ion-title>{{result.name | async}}</ion-title> *** not working ***
</ion-toolbar>
</ion-header>
<ion-content>
</ion-content>
我也尝试过 ng-bind,但无法成功。 API调用很好。响应就在那里,因为代码中可以控制台记录它。但不绑定到页面。
【问题讨论】:
标签: json ionic-framework