I am new to angular, and currently working on my personal project. I have a question about how to insert new data to table row. Can anyone give me snippet/example how to do this?
Here is the form and the table headers:
<!--app.component.html-->
<!--show modal-->
<a href="#" (click)="smModal.show()" popover="Tambah Data Mhs" placement="bottom" triggers="mouseenter:mouseleave">ADD</a>
<!--Modal-->
<div class="container">
<div bsModal #smModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true" id="myModal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title pull-left">Add</h4>
<button type="button" class="close pull-right" aria-label="Close" (click)="smModal.hide()">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form>
<label>ID</label>
<input type="text" class="form-control" placeholder="id">
<label>name</label>
<input type="text" class="form-control" placeholder="name">
<label>year</label>
<input type="text" class="form-control" placeholder="year">
<label>major</label>
<input type="text" class="form-control" placeholder="major">
<label>address</label>
<input type="text" class="form-control" placeholder="address">
<label>Email</label>
<input type="text" class="form-control" placeholder="email">
<label>phone</label>
<input type="text" class="form-control" placeholder="phone"><br>
<button type="submit" class="btn btn-primary">Simpan</button>
<button class="btn btn-danger">Batal</button>
</form>
</div>
</div>
</div>
</div>
<!--enf of modal-->
<!--table-->
<div class="container">
<table class="table table-responsive table-striped">
<tr>
<th>id</th>
<th>name</th>
<th>year</th>
<th>major</th>
<th>address</th>
<th>email</th>
<th>phone</th>
</tr>
</table>
<div>
<!--end of table-->
Here is the typescript file:
//app.component.ts
import { Component } from '@angular/core';
import { TemplateRef } from '@angular/core';
import { BsModalService } from 'ngx-bootstrap/modal';
import { BsModalRef } from 'ngx-bootstrap/modal/modal-options.class';
import { NgIf } from '@angular/common';
@Component({
selector: 'app-root',
styleUrls:['app.component.css'],
templateUrl:'app.component.html',
//template:`<h1 align="center">template</h1>`
})
export class AppComponent
{
title = 'title';
}
What I need to do is simply insert the user input from that from into a table row. Please let me know if more snippets are needed.