Get url parameter using angular js

Get url parameter using angular js

In this Post We Will Explain About is Get url parameter using angular js With Example and Demo.Welcome on infinityknow.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to get the url parameters using AngularJS Example

In this post we will show you Best way to implement $routeParams in AngularJS, hear for Two-way binding for URL parameters in AngularJS with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

angularjs get url parameters in controller

In this Example,First of all Add or Inluce External Libs Like as a(jQuery, css etc..), and then create a simple index.php or index.html page.After that crate a simple javascript file like as a index.js or main.js, It is also add your web-application First Header Part to some priorty set.After that Include your relavant CSS Class.

READ :  The Future of AngularJS Framework

Using Simple $location.search() We can easily simple way to get the query string parameter.

For example

 //url
 https://www.infinityknow.com/#/?username='w3free'&tocken='tocken'
 //Note '#/'
 //simple angularjs In your controller 
 
 $location.search();
 
 Result:
 {
 username : 'w3free',
 tocken:'tocken'
 }

Even We can try ,

$location.search().username 
$location.search().tocken 

//Devloped by infinityknow.com We can write your own logic 

if($location.search().username && $location.search().tocken){
 //Devloped by infinityknow.com do your some logic in this portion
}

Check query parameter is existing

  if($location.search().yourQueryData.indexOf('?') > 0)
  {
 //yes, Good Luck Your query parameter existing 
  }
  else{
 //Sorry!!!. no
  }

How to get the url parameters using AngularJS

$routeProvider.when('/view1/:firstparam/:secondParam', {
    templateUrl: 'partials/partial1.html',    
    controller: 'liveCtrl'
});

And Then in your angular controller inject $routeParams:

.controller('liveCtrl', ['$scope','$routeParams', function($scope, $routeParams) {
  var firstparam = $routeParams.firstparam;
  var secondParam = $routeParams.secondParam; //change here from firstparam to secondParam
  ...
}]);

You are Most welcome in my youtube Channel Please shubscibe my channel. and give me feedBackMore Details……
Angularjs Example

READ :  Angularjs routeprovider pass parameters to controller

Example

I hope you have Got What is $http.get server request in AngularJS And how it works.I would Like to have FeaeBack From My Blog(infinityknow.com) readers.Your Valuable FeedBack,Any Question,or any Comments abaout This Article(infinityknow.com) Are Most Always Welcome.

Add a Comment

Your email address will not be published. Required fields are marked *