Ionic 4, take input value

Asked

Viewed 1,950 times

0

Hello, I’m trying to get the value of an input in Ionic 4, (I’m new in Ionic), follow my code:

Note: I receive as a result: Undefined

html register.:

<ion-header >
  <!--<ion-toolbar>
      //<ion-title>
        //Ionic Blank
      //</ion-title>
    </ion-toolbar> -->
  </ion-header>
<ion-content   >

    <ion-item class="a">  
      <ion-label class="flNome" position="floating">NOME</ion-label>
      <ion-input  [(ngModel)]="title" class="nome" type="text" ></ion-input>
    </ion-item>
   </ion-content>

register.

import { Component, OnInit } from '@angular/core';


import { EmailComposer } from '@ionic-native/email-composer/ngx';

@Component({
  selector: 'app-cadastro',
  templateUrl: './cadastro.page.html',
  styleUrls: ['./cadastro.page.scss'],
})
export class CadastroPage implements OnInit {
 public title: string;

  constructor(private emailComposer : EmailComposer ) { }
  sendEmail() {
    // var local = $("#slc_Local_Reu").val();
     let email = {
       to: '[email protected]',
       cc: '[email protected]',
       
       subject: 'teste',
       body: 'NOME:' + this.title,
       
       isHtml: true
     };
     this.emailComposer.open(email);
 
   }
  
  ngOnInit() {
  }

}

1 answer

3


Try to pass an attribute name containing the same name as its Model.

Ex:

 <ion-input  name="title" [(ngModel)]="title" class="nome" type="text" ></ion-input>
  • 1

    Thank you very much guy worked!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.