我有ngOnInit 2 vars可用项目和标题,项目用于视图,我想“执行”index.html中的setSeoTitle()函数,我该如何实现?
items = [];
title = [];
ngOnInit() {
this.dataService.fetchData(this.slug)
.subscribe(
(data) => {
this.items = data;
this.title = data;
}
);
}
setSeoTitle(item){
this.seoService.setTitle(item[0]['title']);
}
答案 0 :(得分:3)
ngOnInit() {
this.dataService.fetchData(this.slug)
.subscribe(
(data) => {
this.items = data;
this.title = data;
this.setSeoTitle(this.items ); ///<<###< here
}
);
}
答案 1 :(得分:0)
ngOnInit() {
this.dataService.fetchData(this.slug)
.subscribe(
(data) => {
this.items = data;
this.title = data;
this.setSeoTitle(this.item);
}
);
}
答案 2 :(得分:0)
$conn = mysqli_connect($servername, $username, $password, $dbname);
^^^^^