AngularJs – Extracting Querystring

We are discussing about different implementations using AngularJs in previous blogs. Today, let us see how we can access the data from querystring using AngularJs. AngularJs is based on MVC pattern and all requests reach the controller first. We need to extract the query string values in Controller.

$location object is used for extracting the query string parameters in AngularJs. Following code snippet is used for extracting data from querystring ‘user’.

soApp.controller(‘soDetController’, function ($scope, $location) {
var user = $location.search()[‘user’];
if (typeof user != ‘undefined’)
{….}
}

Advertisements

About ambilykk

I am a Technology Evangelist on Microsoft Technologies. I am carrying the passion on Microsoft technologies specifically on web technologies such as ASP .Net and Ajax. My interests also include Azure and Visual Studio. Technology adoption and learning is my key strength and technology sharing is my passion.
This entry was posted in AngularJs, HTML5 and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s