angularjs - 串联调用角度方法-Highcharts
问题描述
我只是学习 Angular 和高脚椅的新手。我的问题是如何串联调用角度方法来动态呈现图表。我提到了这个链接,但我对此一无所知:链接:https ://www.highcharts.com/blog/tutorials/194-using-highcharts-with-angular-js/ 。链接:当我们点击highchart系列时调用一个角度组件方法 请应用我来解决这个问题。
app.component.ts
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
name:string = '';
age:number;
found:boolean;
constructor(private httpClient: HttpClient) { }
onNameKeyUp(event:any){
this.name = event.target.value;
this.found = false;
}
getProfile(){
this.httpClient.get(`https://my-json-server.typicode.com/techsithgit/json-faker-directory/profiles/?name=${this.name}`)
.subscribe(
(data:any[] )=>{
if(data.length){
this.age = data[0].age;
this.found = true;
}
}
)
}
}
app.component.html
<input type ="text" (keyup) = "onNameKeyUp($event)">
<button (click)= "getProfile()">Get User Details</button>
<br>
<div *ngIf="found" >
<span>{{name}}'s age is {{age}}</span>
</div>
解决方案
推荐阅读
- python - 结合sparse和einsum进行大稀疏求和
- javascript - Mongoose 收到错误:MissingSchemaError: Schema has not been registered for model
- python-3.x - 将 Conv1D 添加到 CNN 模型定义时语法无效
- javascript - Javascript:如何检查井字游戏中所有框/单元格的获胜状态?
- xamarin - 在 CopyingFile 部署到真正的 iPhone 变得非常缓慢
- python - 具有非字母数字字符的字段名称的 Pydantic 模型
- java - 为什么热点在同一个源代码中使用不同的汇编风格?
- javascript - 错误:重新渲染太多。React 限制渲染次数以防止无限循环
- adonis.js - Adonis.js api 删除路由不起作用
- python - 如果ID之前取消订单,请填写True/False