Angular routeprovider pass multiple parameters

Angular routeprovider pass multiple parameters

Today, We want to share with you Angular routeprovider pass multiple parameters.
In this post we will show you Angularjs routeprovider pass parameters | $routeParams, hear for angularjs routeprovider multiple parameters we will give you demo and example for implement.
In this post, we will learn about passing parameters to new scope from $routeProvider with an example.

The $routeParams service very easy way to allows you to retrieve all the current set parameters of route parameters.and we can use Angularjs routeParams is a all the service that allows you to new set retrieve the current set dynemically of route parameters with # sign(URL Parameters).

Dependencies

jump to another simple get result page that holds all the basic detail of clicked content. We can all the every page do this by new wiring up a simple level second partial to all the data using $routeParams service.

READ :  vuejs time-range-picker Example - time range picker using Vuejs - timerangepicker

    $route

AngularJS RouteRage Features

  • Use $routeParams pass parameters variables in your view directly. and No more copying $routeParams pass parameters to $scope.
  • Using simple module add to [[rr:… ]] brackets to differentiate it from pass parameters $scope variables.
  • Trigger all the ng-route it once on an HTML element and use it routeParams pass parameters anywhere within the HTML element.
  • Allows you to use simple expressions with your $routeParams, for example: [[rr:productId + 1]].
  • Auto clean up unused square braket to [[rr:… ]] define variables,and some except on errors.
  • Pure AngularJS used. No extra dependency Like as a other libs.

the controller pass parameters can all the data id and then fetch the related routeParams pass parameters content via an simple $http Ajax call. These parameters route pass parameters passed in the route are called simple defination route parameters and are exposed by a integrated all the AngularJS service called $routeParams pass parameters.

READ :  AngularJS Introduction Tutorial

routeprovider with parameters Example

https://infinityknow.com/index.html#books
https://infinityknow.com/index.html#albums
https://infinityknow.com/index.html#games
https://infinityknow.com/index.html#apps

index.html

<html ng-app="liveApp">
<head>
	<title>angularjs routeparams in controller Example</title>
	<meta charset="utf-8">
	<!--some meta info-->
	<meta name="author" content="">
	<meta name="keywords" content="">
	<meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<script src="js/scripts.js"></script>    

</head>
<body>
<div ng-view></div>
	<script src="js/angular.min.js"></script>
	<script src="js/angular-route.min.js"></script>
	<script src="app.js"></script>
</body>

</html>

app.js

var liveApp = angular.module('liveApp', ['ngRoute']);
liveApp.config(['$routeProvider',
  function($routeProvider) {
    $routeProvider.
      when('/', {
        title: 'Pakainfo.com',
        templateUrl: 'home.html',
        controller: 'homeCtrl'
      })
	   .when('/home/:study_id', {
        title: 'infinityknow.com',
        templateUrl: 'Dashboard.html',
        controller: 'dashCtrl'
      })
      .otherwise({
        redirectTo: '/'
      });
}]);

Request Get Method Using Angularjs

$scope.search = function(){
		$http.get('api/index.php/search_sub/'+$scope.keywords).success (function(data){
			$scope.dataSource=data.data;
		});
	}
	
/* Tab panel */
$scope.activeTab = 1;
			
$scope.setActiveTab = function(tabname) {
	$scope.activeTab = tabname;
}

Angularjs : angularjs routeparams example

liveApp.controller('homeCtrl', function ($scope, $http ,$routeParams) {
	$http.get('api/index.php/get_study').success (function(data){
		
		$scope.study_result=data.data;
		//alert(JSON.stringify($scope.study_result));
		//$scope.jsondata = data;
	}); 
});

Example

AngularJS routes enable same way to create different content URLs for different content in your application. Having some different URLs for get the data different content all the enables the user to bookmark get way to URLs to specific content data, and send all the information those URLs to friends like user-scalable etc. In AngularJS each such new bookmarkable URL is called a route.with routeParams

READ :  Auto Post Tweets on Twitter via API Using PHP

Tutorials on all the route with angularjs routeparams source code and complete code example with $routeParams with parameters get implementation also include all the config setting up multiple routes in angularjs.

Add a Comment

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