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.

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.

READ :  Vuejs Computed properties - vue watch computed property Examples

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'});

E-junkie: Sell digital downloads online

E-junkie Provides a Copy-paste buy-now, and cart buttons for selling downloads, codes and tangible products on any website, blog, social media, email and messenger!

Also see:

  1. The Top 10+ Best Webinar Software Platforms For 2020-2021
  2. Build Your Future Godaddy Careers And Jobs
  3. Introduction To Web Hosting Services

config(['$routeProvider', function ($routeProvider) {
	$routeProvider.when('/login/:parameterval1', {
		templateUrl: 'www.infinityknow.com/salesorder.html',
		controller: productCtrl
		});
}]);

Fetch parameters value

The parametervalue can then be accessed in productCtrl as follows:

var fetchvar= $routeParams.parameterval1;

Route Parameters

index.html


<a href="#/about/abcd">About Us + param</a><br />
<a href="#/contact/1234">Contact Us + param</a><br />
<div></div>

app.js

    var infinityknowApp = angular.module("mr4App", ['ngRoute']);

    infinityknowApp.config(['$routeProvider',
        function($routeProvider) {
            $routeProvider.
                    when('/about/:param', {
                        templateUrl: 'about-us.html',
                        controller: 'AboutController'
                    }).
                    when('/contact/:param', {
                        templateUrl: 'contactus.html',
                        controller: 'ContactController'
                    }).
                    otherwise({
                        redirectTo: '/'
                    });
        }]);

    infinityknowApp.controller("AboutController", function($scope, $routeParams) {
        $scope.param_val = $routeParams.param;
		console.log($scope.param_val);
    })

[php]

<h3>Creating a default route</h3>
<p>Routing in AngularJS also supports the facility to have a default route. in config. </p>
<p>
<ul>
otherwise ({
    redirectTo: '/angular'
});
</ul>
</p>

<h3>When the app loads</h3> 
[php]
my4App.run(function ($location, appAuth) {  
	//check auth.
  if (!appAuth.isLoggedIn()) {
    appAuth.saveAttemptUrl();
	//redirect login page
    $location.path('/login');
  }
});

View Demo

READ :  Laravel get last inserted id