如何进行http get请求并传递json对象
这是我的json-Object
{{firstname:"Peter", lastname:"Test"}
Run Code Online (Sandbox Code Playgroud)
这个对象我想传递http请求以获得匹配人员列表.
这怎么可能?此示例仅显示带有json结果的简单get请求.我该如何修改它?
//Component:
person:Person;
persons:Person [];
....
//Whre can I pass the person, here in the service??
getMatchedPersons(){
this.httpService.getMatchedPersons().subscribe(
data => this.persons = data,
error => aller(error)
);
);
//SERVICE
//pass parameters?? how to send the person object here?
getMatchedPersons(){
return this.http.get('url').map(res => res.json());
}
Run Code Online (Sandbox Code Playgroud)
我想在我的Angular 2应用程序中使用DataTable.但这不起作用.Angular 2中没有可能在模板中添加脚本标记.你知道我怎么能这样做吗?我想我必须在systemJs中做一些改变.
list.html:
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Name</th>
<th>Position</th>
<th>Office</th>
<th>Age</th>
<th>Start date</th>
<th>Salary</th>
</tr>
</tfoot>
<tbody>
<tr>
<td>Gavin Cortez</td>
<td>Team Leader</td>
<td>San Francisco</td>
<td>22</td>
<td>2008/10/26</td>
<td>$235,500</td>
</tr>
<tr>
<td>Martena Mccray</td>
<td>Post-Sales support</td>
<td>Edinburgh</td>
<td>46</td>
<td>2011/03/09</td>
<td>$324,050</td>
</tr>
</tbody>
</table>
Run Code Online (Sandbox Code Playgroud)
我的组件:
...
declare var jQuery:any;
..
ngOnInit():any{
console.log("Augerufen");
jQuery('#example').DataTable();
}
...
Run Code Online (Sandbox Code Playgroud)
在我的index.html中,我添加了所需的库:
<!-- Bootstrap Core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/jquery.dataTables.min.css" rel="stylesheet">
<!-- jQuery …
Run Code Online (Sandbox Code Playgroud)