Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to add row in angular dynamically

<table class="table table-striped table-bordered">
    <thead>
        <tr>
            <th>Code</th>
            <th>Name</th>
            <th>Price</th>
            <th>Action</th>
        </tr>
    </thead>
    <tbody>
        <tr *ngFor="let field of fieldArray; let i = index">
            <td>
                <input [(ngModel)]="field.code" class="form-control" type="text" name="{{field.code}}" />
            </td>
            <td>
                <input [(ngModel)]="field.name" class="form-control" type="text" name="{{field.name}}" />
            </td>
            <td>
                <input [(ngModel)]="field.price" class="form-control" type="text" name="{{field.price}}" />
            </td>
            <td>
                <button class="btn btn-default"  type="button" (click)="deleteFieldValue(i)">Delete</button>
            </td>
        </tr>
        <tr>
            <td>
                <input class="form-control" type="text" id="newAttributeCode" [(ngModel)]="newAttribute.code" name="newAttributeCode" />
            </td>
            <td>
                <input class="form-control" type="text" id="newAttributeName" [(ngModel)]="newAttribute.name" name="newAttributeName" />
            </td>
            <td>
                <input class="form-control" type="text" id="newAttributePrice" [(ngModel)]="newAttribute.price" name="newAttributePrice" />
            </td>
            <td>
                <button class="btn btn-default" type="button" (click)="addFieldValue()">Add</button>
            </td>
        </tr>
    </tbody>
</table>
Comment

PREVIOUS NEXT
Code Example
Javascript :: for each append to document 
Javascript :: remove property from object javascript 
Javascript :: js create and call function 
Javascript :: geolocation 
Javascript :: python run javascript 
Javascript :: js contains 
Javascript :: how to loop through all tags in html 
Javascript :: three ways of writing a function in javascript 
Javascript :: yup.array not working 
Javascript :: export to csv - Javascript - Download CSV as File 
Javascript :: string date to date in javascript 
Javascript :: javaScript setMonth() Method 
Javascript :: split text javascript 
Javascript :: how to check with jquery if bootstrap modal is hidden or shown 
Javascript :: how to delete current clicked item in array react 
Javascript :: index of javascript 
Javascript :: replaceAll vs replace vs split join 
Javascript :: js remove trailling lines 
Javascript :: svelte on destroy 
Javascript :: mongoose + populate 
Javascript :: javascript check string empty 
Javascript :: Fetch Data Using Getx 
Javascript :: javascript modify href attr 
Javascript :: react native camscanner application mobile code 
Javascript :: javascript true string to boolean 
Javascript :: request-promise-native error RequestError: Error: unable to verify the first certificate 
Javascript :: confetti canvas 
Javascript :: rating calculator formula javascript 
Javascript :: remove parent element javascript 
Javascript :: yarn create react app in current directory 
ADD CONTENT
Topic
Content
Source link
Name
1+2 =