JavaScript - Limit Table Row Using AngularJS
Submitted by razormist on Monday, January 14, 2019 - 21:56.
In this tutorial we will create Limit Table Row using AngularJS. AngularJS is a structural framework for dynamic web apps. It is a kind of template that extends HTML to a new level of coding techniques. It is mostly used by other well known site for creating a template. So let's get started. So Let's do the coding...
There you have it we successfully created a Limit Table Row using AngularJS. I hope that this very simple tutorial help you to what you are looking for. For more updates and tutorials just kindly visit this site. Enjoy Coding!!
Getting started:
First you will need to download & install the AngularJS here's the link https://angularjs.org/. And download & install XAMPP or any local server that run PHP scripts. Here's the link for XAMPP server https://www.apachefriends.org/index.html.Creating the Main Interface
This code contains the interface of the application. This code will render application and display the form. To do that just kindly write these block of code inside the text editor and save it as index.html.- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/>
- <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/>
- </head>
- <body ng-app="myModule">
- <nav class="navbar navbar-default">
- <div class="navbar-brand">
- </div>
- </nav>
- <div class="col-md-6 well">
- <hr style="border-top:1px dotted #ccc;"/>
- <div ng-controller="myController">
- <div class="form-inline">
- </div>
- <br />
- <table class="table table-bordered">
- <thead class="alert-info">
- <tr>
- </tr>
- </thead>
- <tbody>
- <tr ng-repeat="student in students | orderBy: 'lastname' | limitTo:limitRow">
- </tr>
- </tbody>
- </table>
- </div>
- </div>
- </body>
- </html>
Creating the Script
This code contains the main function of the application. This code will limit the display of row base on the value of input textbox. To that just kindly copy and write these block of codes inside the text editor, then save it as script.js.- var app = angular
- .module("myModule", [])
- .controller("myController", function($scope){
- var students = [
- {firstname: "Ben", lastname: "Tennyson", address: "Canada"},
- {firstname: "Erika", lastname: "Barns", address: "Germany"},
- {firstname: "Cassie", lastname: "Lang", address: "New York"},
- {firstname: "Alex", lastname: "Wilder", address: "Tokyo"},
- {firstname: "Nico", lastname: "Minoru", address: "Japan"},
- {firstname: "Ash", lastname: "Ketchump", address: "Pallet"},
- {firstname: "Bruce", lastname: "Banner", address: "USA"}
- ];
- $scope.students = students;
- $scope.limitRow = students.length;
- });
Add new comment
- 103 views