sonexteen
Integration Flow Designer
2
MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1
300 XP
In this tutorial we will create a Custom Filter Using AngularJS. AngularJS is a JavaScript-based open-source front-end web application framework . 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.
Getting started:
First you will need to download & install the AngularJS here's the link https://angularjs.org/.
And this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
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 Script
This code contains the main function of the application. This code will filter a portion of data into a new thing by getting the target id. To that just kindly copy and write these block of codes inside the text editor, then save it as shown below.
script.js
custome_filter.js
There you have it we successfully created a Custom Filter 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 will need to download & install the AngularJS here's the link https://angularjs.org/.
And this is the link for the bootstrap that i used for the layout design https://getbootstrap.com/.
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
=
"container-fluid"
>
- <a
class
=
"navbar-brand"
href
=
"https://sourcecodester.com"
>
Sourcecodester</
a
>
- </
div
>
- </
nav>
- <div
class
=
"col-md-3"
></
div
>
- <div
class
=
"col-md-6 well"
>
- <h3
class
=
"text-primary"
>
JavaScript - Custom Filter Using AngularJS</
h3
>
- <hr
style
=
"border-top:1px dotted #ccc;"
/
>
- <table
class
=
"table table-bordered"
>
- <thead
class
=
"alert-info"
>
- <tr
>
- <th
>
Firstname</
th
>
- <th
>
Lastname</
th
>
- <th
>
Civil Status</
th
>
- <th
>
Address</
th
>
- </
tr
>
- </
thead
>
- <tbody
style
=
"background-color:#fff;"
>
- <tr
ng-repeat=
"member in members | orderBy: 'lastname'"
>
- <td
>
{{member.firstname}}</
td
>
- <td
>
{{member.lastname}}</
td
>
- <td
>
{{member.civil_status | civil_status}}</
td
>
- <td
>
{{member.address}}</
td
>
- </
tr
>
- </
tbody
>
- </
table
>
- </
div
>
- <script
src
=
"js/angular.js"
></
script
>
- <script
src
=
"js/script.js"
></
script
>
- <script
src
=
"js/custom_filter.js"
></
script
>
- </
body
>
- </
html
>
Creating the Script
This code contains the main function of the application. This code will filter a portion of data into a new thing by getting the target id. To that just kindly copy and write these block of codes inside the text editor, then save it as shown below.
script.js
- var
app =
angular.module
(
"myModule"
,
[
]
)
- .controller
(
"myController"
,
function
(
$scope)
{
- var
members =
[
- {
firstname:
"John"
,
lastname:
"Smith"
,
civil_status:
1
,
address:
"USA"
}
,
- {
firstname:
"Claire"
,
lastname:
"Jacks"
,
civil_status:
2
,
address:
"Tokyo"
}
,
- {
firstname:
"Venice"
,
lastname:
"Hudson"
,
civil_status:
2
,
address:
"Germany"
}
,
- {
firstname:
"Luke"
,
lastname:
"Cage"
,
civil_status:
2
,
address:
"France"
}
- ]
;
- $scope.members
=
members;
- }
)
;
custome_filter.js
- app.filter
(
"civil_status"
,
function
(
)
{
- return
function
(
civil_status)
{
- switch
(
civil_status)
{
- case
1
:
- return
"Single"
;
- case
2
:
- return
"Married"
;
- }
- }
- }
)
There you have it we successfully created a Custom Filter 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.