Cristian Lagla
Cristian Lagla

Reputation: 31

get value input text with button angular 7

I want to get the text of an input text and saving it in a variable using a button. To use it as a parameter in a query in firebase.

.html

<input type="text" class="form-control" ng-model="value1" id="textCI" placeholder="C.I." >

component.ts

<--ResultCI =valor input text-->

 buscarCI(){
    let query=null;
    query=this.servicio.getUsuarioFiltro(this.ResultCI);
    query.snapshotChanges()
      .map(changes=>{
        return changes.map(c=>({key:c.payload.key, ...c.payload.val()}))
      }).subscribe(contactos =>{
        this.contactos=contactos
      });
  }

Upvotes: 2

Views: 11346

Answers (1)

Sajeetharan
Sajeetharan

Reputation: 222582

You are using the angularjs syntax which is ng-model, instead you should use [(ngModel)]

<input type="text" class="form-control" [(ngModel)]="value1" id="textCI" placeholder="C.I." >

you should be able to access in the component with this.value1

Upvotes: 4

Related Questions