Angular 7 - Dynamic Forms and passing a function through
0
Using Angular's Dynamic forms I'm building a new input field form.ts usernameCallback(body) { console.log(`hello ${body}`); this.usernameService.post(body) .subscribe( data => { console.log(data); }, error => { console.warn(`Error: ${error}`); } ); } ngOnInit() { new InputField({ key: 'username', label: 'Username', value: '', placeholder: 'Enter username', required: true, callback: this.usernameCallback }), } So this is the basics of the code. I have inside UsernameService a method post() which sends an http post request. usernameCallback() is added to the InputField and has the type of Function