SlideShare a Scribd company logo
How to catch query string in
AngularJs using $Location
Whenwe use AngularJsandwant passsome value fromone page to anotherpage.
We have optionstouse $Location to catch querystring.TodayI am showinghow touse $Location to
catch QueryString.
Plnkr - http://plnkr.co/edit/TNX06WFx0n6p1mSLPKfP?p=preview
Followingcode pass"accountNo"paramerterwith "1001" value toindex1.html.We will catchthat
parameterintoindex1.htmlpage.
Note:Whenyoupassingquerystringfromone page to anotherpage must use "#?" to passquerystring.
Use followingformattopassquerystring.
" #?accountNo=1001"
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Howto catch query stringin AngularJs</title>
<linkrel="stylesheet"href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.js"></script>
</head>
<body ng-app="queryStringApp">
<div ng-controller="firstCtrl">
<h3> Catch query string inAngularJs with $Location </h3>
For pass query string to another page use followingformat
<br><br>
" #?accountNo=1001"
<br>
<br> <br>
<a href="index1.html#?accountNo=1001">click here to password querystring to anotherpage </a>
</div>
</body>
</html>
Index1.html
<!DOCTYPE html>
<html>
<head>
<title>Howto catch query stringin AngularJs</title>
<linkrel="stylesheet"href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.js"></script>
<script>
var app = angular.module('queryStringApp',[]);
app.controller('firstCtrl',function($scope,$location) {
alert("AccountNumber is - "+ $location.search()['accountNo']);
$scope.accountNo=$location.search()['accountNo'];
});
</script>
</head>
<body ng-app="queryStringApp">
<div ng-controller="firstCtrl">
Account No - {{accountNo}}
</div>
</body>
</html>

More Related Content

Similar to How to catch query string in angular js (20)

DOCX
Sharing Data between controllers in different ways.
Amar Shukla
 
DOCX
Different way to share data between controllers in angular js
codeandyou forums
 
PPT
AngularJS Mobile Warsaw 20-10-2014
Dariusz Kalbarczyk
 
DOCX
Angular js
prasaddammalapati
 
PDF
The Ring programming language version 1.8 book - Part 50 of 202
Mahmoud Samir Fayed
 
KEY
Google
soon
 
PPTX
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
Learnimtactics
 
DOCX
Controller in AngularJS
Brajesh Yadav
 
PDF
Denver emberjs-sept-2015
Ron White
 
PDF
Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Jamie Matthews
 
PDF
jQuery and Rails, Sitting in a Tree
adamlogic
 
PPT
Angular data binding by Soft Solutions4U
sharsen
 
PPTX
Angular directive filter and routing
jagriti srivastava
 
PDF
Course CodeSchool - Shaping up with Angular.js
Vinícius de Moraes
 
PPTX
Angular js
Brian Atkins
 
PPTX
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
crokitta
 
PDF
Angular js - the beginning
A.K.M. Ahsrafuzzaman
 
PPTX
AngularJS & Drupal - Андрей Березовский
DrupalCamp MSK
 
PDF
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Matt Raible
 
PPTX
Angular js PPT
Imtiyaz Ahmad Khan
 
Sharing Data between controllers in different ways.
Amar Shukla
 
Different way to share data between controllers in angular js
codeandyou forums
 
AngularJS Mobile Warsaw 20-10-2014
Dariusz Kalbarczyk
 
Angular js
prasaddammalapati
 
The Ring programming language version 1.8 book - Part 50 of 202
Mahmoud Samir Fayed
 
Google
soon
 
AngularJs Superheroic JavaScript MVW Framework Services by Miracle Studios
Learnimtactics
 
Controller in AngularJS
Brajesh Yadav
 
Denver emberjs-sept-2015
Ron White
 
Five Pound App talk: hereit.is, Web app architecture, REST, CSS3
Jamie Matthews
 
jQuery and Rails, Sitting in a Tree
adamlogic
 
Angular data binding by Soft Solutions4U
sharsen
 
Angular directive filter and routing
jagriti srivastava
 
Course CodeSchool - Shaping up with Angular.js
Vinícius de Moraes
 
Angular js
Brian Atkins
 
Oracle Application Express & jQuery Mobile - OGh Apex Dag 2012
crokitta
 
Angular js - the beginning
A.K.M. Ahsrafuzzaman
 
AngularJS & Drupal - Андрей Березовский
DrupalCamp MSK
 
Use Angular Schematics to Simplify Your Life - Develop Denver 2019
Matt Raible
 
Angular js PPT
Imtiyaz Ahmad Khan
 

More from codeandyou forums (16)

DOCX
How to validate server certificate
codeandyou forums
 
DOCX
How to call $scope function from console
codeandyou forums
 
DOCX
Understand components in Angular 2
codeandyou forums
 
DOCX
Understand routing in angular 2
codeandyou forums
 
DOCX
How to setup ionic 2
codeandyou forums
 
DOCX
MongoDB 3.2.0 Released
codeandyou forums
 
DOCX
Welcome to ionic 2
codeandyou forums
 
DOCX
What is JSON? Why use JSON? JSON Types? JSON Helpful Tools?
codeandyou forums
 
DOCX
How to install ssl certificate from .pem
codeandyou forums
 
DOCX
Protractor end-to-end testing framework for angular js
codeandyou forums
 
DOCX
How routing works in angular js
codeandyou forums
 
DOCX
How to use proxy server in .net application
codeandyou forums
 
DOCX
Angular.js interview questions
codeandyou forums
 
DOCX
How to set up a proxy server on windows
codeandyou forums
 
DOCX
What is $root scope in angularjs
codeandyou forums
 
DOCX
How to save log4net into database
codeandyou forums
 
How to validate server certificate
codeandyou forums
 
How to call $scope function from console
codeandyou forums
 
Understand components in Angular 2
codeandyou forums
 
Understand routing in angular 2
codeandyou forums
 
How to setup ionic 2
codeandyou forums
 
MongoDB 3.2.0 Released
codeandyou forums
 
Welcome to ionic 2
codeandyou forums
 
What is JSON? Why use JSON? JSON Types? JSON Helpful Tools?
codeandyou forums
 
How to install ssl certificate from .pem
codeandyou forums
 
Protractor end-to-end testing framework for angular js
codeandyou forums
 
How routing works in angular js
codeandyou forums
 
How to use proxy server in .net application
codeandyou forums
 
Angular.js interview questions
codeandyou forums
 
How to set up a proxy server on windows
codeandyou forums
 
What is $root scope in angularjs
codeandyou forums
 
How to save log4net into database
codeandyou forums
 
Ad

Recently uploaded (20)

PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PDF
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
PDF
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
PDF
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
PPTX
Human Resources Information System (HRIS)
Amity University, Patna
 
PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
PPTX
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
PDF
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PPTX
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
PPTX
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
PPTX
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
PPTX
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
PPTX
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Revenue streams of the Wazirx clone script.pdf
aaronjeffray
 
Alarm in Android-Scheduling Timed Tasks Using AlarmManager in Android.pdf
Nabin Dhakal
 
SciPy 2025 - Packaging a Scientific Python Project
Henry Schreiner
 
Tally software_Introduction_Presentation
AditiBansal54083
 
Human Resources Information System (HRIS)
Amity University, Patna
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
SAP Firmaya İade ABAB Kodları - ABAB ile yazılmıl hazır kod örneği
Salih Küçük
 
Agentic Automation: Build & Deploy Your First UiPath Agent
klpathrudu
 
Online Queue Management System for Public Service Offices in Nepal [Focused i...
Rishab Acharya
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
Hardware(Central Processing Unit ) CU and ALU
RizwanaKalsoom2
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
Equipment Management Software BIS Safety UK.pptx
BIS Safety Software
 
In From the Cold: Open Source as Part of Mainstream Software Asset Management
Shane Coughlan
 
Java Native Memory Leaks: The Hidden Villain Behind JVM Performance Issues
Tier1 app
 
Change Common Properties in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Ad

How to catch query string in angular js

  • 1. How to catch query string in AngularJs using $Location
  • 2. Whenwe use AngularJsandwant passsome value fromone page to anotherpage. We have optionstouse $Location to catch querystring.TodayI am showinghow touse $Location to catch QueryString. Plnkr - http://plnkr.co/edit/TNX06WFx0n6p1mSLPKfP?p=preview Followingcode pass"accountNo"paramerterwith "1001" value toindex1.html.We will catchthat parameterintoindex1.htmlpage. Note:Whenyoupassingquerystringfromone page to anotherpage must use "#?" to passquerystring. Use followingformattopassquerystring. " #?accountNo=1001" Index.html <!DOCTYPE html> <html> <head> <title>Howto catch query stringin AngularJs</title> <linkrel="stylesheet"href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.js"></script> </head> <body ng-app="queryStringApp"> <div ng-controller="firstCtrl"> <h3> Catch query string inAngularJs with $Location </h3> For pass query string to another page use followingformat <br><br> " #?accountNo=1001" <br> <br> <br> <a href="index1.html#?accountNo=1001">click here to password querystring to anotherpage </a> </div> </body> </html>
  • 3. Index1.html <!DOCTYPE html> <html> <head> <title>Howto catch query stringin AngularJs</title> <linkrel="stylesheet"href="http://getbootstrap.com/2.3.2/assets/css/bootstrap.css"> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.4/angular.js"></script> <script> var app = angular.module('queryStringApp',[]); app.controller('firstCtrl',function($scope,$location) { alert("AccountNumber is - "+ $location.search()['accountNo']); $scope.accountNo=$location.search()['accountNo']; }); </script> </head> <body ng-app="queryStringApp"> <div ng-controller="firstCtrl"> Account No - {{accountNo}} </div> </body> </html>