2

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
      });
  }
2

1 Answer 1

4

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

Sign up to request clarification or add additional context in comments.

1 Comment

@CristianLagla Might be you forget to import FormsModule in modules.ts

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.