dimanche 3 juin 2018

access to checkbox in typescript

I have a form in html like this:

<form (ngSubmit)="addNewBrand(f)" #f="ngForm">
    <label>name:</label>
    <input type="text" name="name" required ngModel #name="ngModel">

    <label>active:</label>
    <input type="checkbox" name="active" required ngModel #active="ngModel">

    <button type="submit" [disabled]="!f.valid">Save</button>

</form>

in ts file:

addNewBrand(form:NgForm){
    console.log(form.value.name + ' -  ' + form.value.active);
}

but I can't access to checkbox in ts file. What should I do?




Aucun commentaire:

Enregistrer un commentaire