ng add ng-zorro-antd 安装这个就是直接导入了,不需要我们再次的引入
1 app.module.ts配置
import {HttpClientModule} from '@angular/common/http'
imports: [
...
HttpClientModule,
],
2 在发送http请求的组件中配置
import {HttpClient} from '@angular/common/http'
export class ContentComponent implements OnInit {
public programs:any;
constructor(public http:HttpClient) { }
ngOnInit() {
var url:string="http://192.168.14.15:5000/dj/program?rid=336355127"
this.http.get(url).subscribe(res=>{
console.log(res['programs'])
this.programs=res['programs']
})
}
tips:ngOnInit() {} //相当于onLoad(),mounted()生命周期