我有以下代码,其中包含多个订阅。我需要实现的是这样的:
我的问题:有没有更好的方法来执行这些嵌套订阅?这样做是一个好习惯吗?
this.activatedRoute.data.pipe(
map((data) => {
this.user = data['user'];
this.product = data['product'];
return this.product;
})
).subscribe(result => {
if (this.product === null) {
this.router.navigate(['/home']);
} else {
this.displayCurrency = this.dataService.getCurrencySymbolById(this.product.currency);
this.userService.getUser(this.product.createdBy).subscribe(seller => {
this.seller = seller;
this.ratingService.getRatingByUserId(seller.id).subscribe(rating => {
this.rating = rating;
})
});
}
});
Run Code Online (Sandbox Code Playgroud) 我是Javascript的新手,特别是在JSON和Jquery上.我已经成功实现了FullCalendar的月度视图,但是无论如何根据用户点击月视图的日期显示或弹出日视图?任何帮助将非常感激
我有以下数组 (testArray),我希望将所有州提取到字符串中 ('Arizona','Alaska','Florida','Hawaii','Gujarat','Goa','Punjab'...) . 有没有更简单的方法来做到这一点?
let testArray: State[];
testArray = this.getStates();
getStates() {
return [
new State(1, 1, 'Arizona'),
new State(2, 1, 'Alaska'),
new State(3, 1, 'Florida'),
new State(4, 1, 'Hawaii'),
new State(5, 2, 'Gujarat'),
new State(6, 2, 'Goa'),
new State(7, 2, 'Punjab'),
new State(8, 3, 'Queensland'),
new State(9, 3, 'South Australia'),
new State(10, 3, 'Tasmania'),
new State(11, 4, 'Penang')
];
}
Run Code Online (Sandbox Code Playgroud)