0

All I'm a newbie in learning Angular and highchairs. My issue is how to call angular method in series to render charts dynamically. I referred this link ,but i'm not understanding anything from that: link:https://www.highcharts.com/blog/tutorials/194-using-highcharts-with-angular-js/. link: Call an angular component method when we click on highchart series Kindly app me to solve this.

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>
Success
  • 35
  • 2
  • 9

0 Answers0