There is search.component.html , and search.component.ts .

In the html document, the markup of the search field with input fields, when entering in these fields, you must pass all values ​​to search.component.ts . The question is how to implement this without cluttering the search.component.html logic.

  @Component({ ... }) export class SearchComponent { myMethod() { // тут получить значения всех инпутов, // могу ли я хранить ссылки на них и тут тянуть value } } 

I have very little knowledge in this area, if I didn’t write or write, please indicate in the comments.

    1 answer 1

    Use ngModel :

     @Component({ selector: 'my-app', providers: [], template: ` <div> <input [(ngModel)] = "value1"> <input [(ngModel)] = "value2"> <button (click)="search()">Search</button> </div> `, directives: [] }) export class App { value1: string; value2: string; constructor() { } search(){ alert(`value1: ${this.value1} \n value2: ${this.value2}`); } } 

    A working example: plnkr