I have 2 div,I need hide and show it based on dropdown selection.When my selected option is chartdata 'ChartData' div will show again when I select tabledata 'TableData' div will show. I can easily do it with ngif,but the problem is 'TableData' div is generating from plugin,I cannot put there ngif tag so I need to use its id only.Is there any way to do it with angular 7. Here is the code.
home.component.html
<select (change)="onChangeEvent($event)"><option>Chartdata</option><option>Tabledata</option></select>
<div id="chart">ChartData</div>
<div id="table">TableData</div>
home.component.ts
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css']
})
export class HomeComponent implements OnInit {
nestedjson:any;
constructor(private formBuilder: FormBuilder) {
}
ngOnInit() {
this.nestedjson = [{"name":"parent1","value":["child11","child12"]},{"name":"parent2","value":["child2"]},{"name":"parent3","value":["child3"]}];
}
onChangeEvent(ev) {
console.log(ev.target.value); // should print option1
}
}