| | |
| | | styleUrls: ["./home-page.component.less"] |
| | | }) |
| | | export class HomePageComponent implements OnInit { |
| | | public cardData: {'api'?:number,'temperature'?:number,'windDirection'?: string,'pm2.5'?: number} |
| | | public cardData: {'api'?:number,'temperature'?:number,'windDirection'?: string,'pm25'?: number} |
| | | = {}; |
| | | constructor( |
| | | private http:_HttpClient, |
| | |
| | | this.http.get('http://sapi.7drlb.com/api/mj?cityID=1102&apiKey=aqi') |
| | | |
| | | ).subscribe( |
| | | ([conRes,aqiRes]) => { |
| | | debugger; |
| | | console.log(conRes); |
| | | console.log(aqiRes); |
| | | ([conRes,aqiRes]) => { |
| | | console.log(conRes); |
| | | console.log(aqiRes); |
| | | if( conRes.code == 0 && aqiRes.code == 0 ) { |
| | | this.cardData.windDirection =conRes.data.condition.windDir; |
| | | this.cardData.temperature =conRes.data.condition.temp; |
| | | this.cardData.api = aqiRes.data.aqi.value; |
| | | this.cardData.pm25 = aqiRes.data.aqi.pm25; |
| | | } |
| | | } |
| | | ) |
| | | } |