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’)
{….}
}