Angular location redirect with parameters

Angular location redirect with parameters

Today, We want to share with you Angular location redirect with parameters.
In this post we will show you Angular location redirect with parameters, hear for Angular location redirect with parameters we will give you demo and example for implement.
In this post, we will learn about Angular location redirect with parameters with an example.

AngularJS supports The (SPA) using routing module to ngRoute.and This routing module (spa)simple acts based on the url.

READ :  Vuejs Simple Line Chart using JSON - javascript

AngularJS routes all pages enable you to create different URLs for different content display in your web-application.

AngularJS routes module can be used to show different page content in an AngularJS web-app based on the different part of the page URL after the # sign (the route),and practically content enabling bookmarkable all links into your AngularJS web-application.

AngularJS routes web app that loads a single HTML page(spa) and dynamically all updates that page as the user interacts with the web application.

$location.path(‘/myURL/’).search({param: ‘value’});

config([‘$routeProvider’, function ($routeProvider) {
$routeProvider.when(‘/login/:parameterval1’, {
templateUrl: ‘’,
controller: productCtrl


Fetch parameters value

The parametervalue can then be accessed in productCtrl as follows:

READ :  Laravel 6 Call controller method from another controller

var fetchvar= $routeParams.parameterval1;

Route Parameters



About Us + param
Contact Us + param




var infinityknowApp = angular.module(“mr4App”, [‘ngRoute’]);

function($routeProvider) {
when(‘/about/:param’, {
templateUrl: ‘about-us.html’,
controller: ‘AboutController’
when(‘/contact/:param’, {
templateUrl: ‘contactus.html’,
controller: ‘ContactController’
redirectTo: ‘/’

infinityknowApp.controller(“AboutController”, function($scope, $routeParams) {
$scope.param_val = $routeParams.param;


Creating a default route

Routing in AngularJS also supports the facility to have a default route. in config.

    otherwise ({
    redirectTo: ‘/angular’

When the app loads

[php] ($location, appAuth) {
//check auth.
if (!appAuth.isLoggedIn()) {
//redirect login page

View Demo

Leave a Comment