Angular form 5 typescript

0

I would like a help with this modal, I want to pass the value of the form to a function and I do not know how. angular position 5

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"/>


<!-- Button trigger modal -->
<div class="row">
  <div class="col-md-3"></div>
  <button type="button" class="btn btn-outline-danger col-md-6" data-toggle="modal" data-target="#user">
    Ingresa aqui tu nombre
  </button>

</div>


<!-- Modal -->

<div class="modal fade" id="user" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title text-center" id="user">Bienvenido: Ingrese su nombre</h5>
        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
        <form>
            <input type="text" class="form-control" id="user">
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-secondary" data-dismiss="modal">Cerrar</button>
        <button type="button" class="btn btn-primary" >Guardar</button>
      </div>
    </div>
  </div>
</div>

 <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
  
  
    
asked by Mario 18.04.2018 в 02:19
source

1 answer

1

In your case it would be to add the variable in the component and the binding to the template

Add variable to the component

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

@Component({
  selector: 'example-app',
  template: 'template.component.html',
})
export class SimpleNgModelComp {
  user: string = '';
}

Add binding to input

<!-- Modal -->

<input [(ngModel)]="user" name="user" type="text" class="form-control" id="user">

Documentation on this subject

link

    
answered by 18.04.2018 / 08:33
source