I was wondering how can I use string value of JSON object that I get from input.
export class NavComponent implements OnInit {
formVar: FormGroup;
items = [];
constructor(private api: ApiService, private fb: FormBuilder) {}
ngOnInit(): void {
this.formVar = this.fb.group({
search:''
});
}
onSubmit(){
this.api.search(this.formVar.value).subscribe(
data => {
this.items = data;
console.log(this.formVar.value);
}
)
}
}
The output for fromVar.value is this:
{search: "dfsdf"}
search: "dfsdf"
__proto__: Object
but I need only string value inside this object.
question from:
https://stackoverflow.com/questions/65599942/how-to-use-value-of-json-object-in-typescript 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…