1. angular 中自带的有http请求
    1. //app.module.ts中去注册
    2. +import {HttpClientModule} from '@angular/common/http'
    3. @NgModule({
    4. ...
    5. imports: [
    6. BrowserModule,
    7. + HttpClientModule
    8. ]
    9. ...
    10. })
    1. //app.component.ts配置
    2. + import {HttpClient} from '@angular/common/http'
    3. export class AppComponent {
    4. + movies:any = [];
    5. + constructor(public http:HttpClient){}
    6. + ngOnInit(){
    7. + var url:string = "http://localhost:8000/top250";
    8. + this.http.get(url).subscribe((res:any)=>{
    9. + this.movies = res.result; //设置data中的数据
    10. })
    11. }
    12. }