我注意到是否有可能,但这就是我想要做的事情:
我想根据点击的td
来填充空模板,例如,如果您点击<td *ngFor="let user of userService.user | async">{{user.data.server1}}</td>
,那么您将移至server1.component.ts详细信息页面,其中包含server1
Json对象详细信息
==&GT;我发现requestOptions.params
的东西是一个想法..所以它就像数据是从Json提取的get请求获取并根据选项卡中选定的行返回数据
当您执行以下操作时,与php相同:<?php
echo $_GET['link'];
在1行= 1 Json对象= 1页(带有制表符和子节点的父显示每行的详细信息)
换句话说,每个单击的选项卡行将显示有关所选Json对象的大量详细信息(图表,%指示符)
注意:我不想为每一行编写足够多的子组件,我想只需要一个子组件填充不同的对象Json,每行不同......
我认为使用该方法可能有效How to pass url arguments (query string) to a HTTP request on Angular 2
我的请求也与该问题有点类似,我实际上是在尝试调整该代码:Angular http service clear RequestOptions search parameters
不确定是否需要routerLink,或者使用正确的http服务配置可以实现一切
如果有人有想法?提前谢谢......
JSON:
user {
{ data
}, {
server1 {
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
server2 {
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
"zipcode": "92998-3874",
"geo": {
"lat": "-37.3159",
"lng": "81.1496"
}
},
}
}
tab.html:
<table>
<tr routerLink=""/my-Server1>
<td *ngFor="let user of userService.user | async">{{user.data.server1}}</td>
</tr>
</table>
service.ts:
@Injectable()
export class UserService {
users: Observable<User[]>;
constructor (public http: Http) {
const tick$ = Observable.timer(100, 60000);
this.users = tick$.flatMap(() => http.get(usersURL)).map(res => [res.json()]).publishBehavior(<User[]>[]).refCount();
}
}
server1.html:
<div ngFor=""let user of userService.user | async"">{{server1.app.id}}
</div>
<div ngFor=""let user of userService.user | async"">{{server1.tol.name}}</div>
<p ngFor="let user of userService.user | async">{{server1.book.51}}</p>
.. 注意 server1.html
模板中有很多其他内容,tr
tab.html