【发布时间】:2017-01-31 12:09:08
【问题描述】:
我创建了一个返回对象数组的服务。如何将服务的结果传递给另一个函数进行进一步处理。
我的订阅
showFeed(){
this.service.getCompanies().subscribe((companies) => {
//console.log(companies);
console.log(companies.rss.channel.item);
this.items = companies.rss.channel.item;
});
}
//How do I pass the result of showFeed() to addItem()
additem(){
this.hostnamesMap={} // hostname as key, and an array of items as value
this.items.map((item) => {
var wordCount = item.link.split("/");
var result = wordCount[0] + "//" + wordCount[2];
if(!this.hostnamesMap[result]) { // create an entry of not existing
this.hostnamesMap[result] = [item];
} else { // add item to already existing entry
this.hostnamesMap[result].push(item);
}
});
}
【问题讨论】:
-
结果在里面,你可以用右箭头访问它。
-
“右箭头”是什么意思
-
this._todos._value 不起作用
-
上下文没有定义主题。
-
那么,怎么办?我被卡住了!!!