ItsZuen
Social Outreach Coordinator
LEVEL 1
200 XP
This simple code will show you how to do Display Array Object using AngularJS. The code will dynamically populate the HTML table by an array object. With the use of AngularJS plugin it is easier to manipulate with arrays. To learn more about this, just follow the steps below.
Getting started:
First you have to download & install XAMPP or any local server that run PHP scripts. Here's the link for XAMPP server https://www.apachefriends.org/index.html.
And, this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
Lastly, you will need to download the AngularJS here's the link https://angularjs.org/.
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 this as index.html.
Creating the Main Function
This code contains the main function of the application. This code will display a list of an array object. To that just kindly copy and write these block of codes inside the text editor, then save it as shown below.
There you have it we successfully created a Display Array Object 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!!
Download
Getting started:
First you have to download & install XAMPP or any local server that run PHP scripts. Here's the link for XAMPP server https://www.apachefriends.org/index.html.
And, this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
Lastly, you will need to download the AngularJS here's the link https://angularjs.org/.
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 this as index.html.
- <!DOCTYPE html>
- <html
lang
=
"en"
ng-app =
"myModule"
>
- <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-controller=
"myController"
>
- <nav class
=
"navbar navbar-default"
>
- <div
class
=
"containet-fluid"
>
- <a
class
=
"navbar-brand"
href
=
"https://www.sourcecodester.com"
>
Sourcecodester</
a
>
- </
div
>
- </
nav>
- <div
class
=
"col-md-3"
></
div
>
- <div
class
=
"col-md-6 well"
>
- <h3
class
=
"text-primary"
>
Display Array Object Using AngularJS</
h3
>
- <hr
style
=
"border-top:1px dotted #ccc;"
/
>
- <div
class
=
"container-fluid"
>
- <button
ng-click=
"getArray();"
class
=
"btn btn-primary"
>
Display Array</
button
>
- <br
/
><br
/
>
- <table
class
=
"table table-bordered"
>
- <thead
class
=
"alert-info"
>
- <tr
>
- <th
>
Member ID</
th
>
- <th
>
Firstname</
th
>
- <th
>
Lastname</
th
>
- <th
>
Grade</
th
>
- </
tr
>
- </
thead
>
- <tbody
>
- <tr
ng-repeat =
"student in students"
>
- <td
>
{{$index+1}}</
td
>
- <td
>
{{student.firstname}}</
td
>
- <td
>
{{student.lastname}}</
td
>
- <td
>
{{student.address}}</
td
>
- </
tr
>
- </
tbody
>
- </
table
>
- </
div
>
- </
div
>
- </
body
>
- <script
src
=
"js/jquery-3.2.1.min.js"
></
script
>
- <script
src
=
"js/angular.js"
></
script
>
- <script
src
=
"js/script.js"
></
script
>
- <script
src
=
"js/bootstrap.js"
></
script
>
- </
html
>
Creating the Main Function
This code contains the main function of the application. This code will display a list of an array object. To that just kindly copy and write these block of codes inside the text editor, then save it as shown below.
- var
app =
angular.module
(
"myModule"
,
[
]
)
- .controller
(
"myController"
,
function
(
$scope)
{
- $scope.arrays
=
[
- {
firstname:
"John"
,
lastname:
"Smith"
,
address:
"New York"
}
,
- {
firstname:
"Claire"
,
lastname:
"Temple"
,
address:
"Racoon City"
}
,
- {
firstname:
"John"
,
lastname:
"Wick"
,
address:
"Pearl Harbor"
}
,
- ]
;
- $scope.getArray
=
function
(
)
{
- $scope.students
=
$scope.arrays
;
- }
- }
)
;
There you have it we successfully created a Display Array Object 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!!
Download
You must upgrade your account or reply in the thread to view hidden text.