Angularjs routeprovider pass parameters to controller
Welcome to the In infinityknow.com website! You will Step By Step learn web programming, easy and very fun. This website allmost provides you with a complete web programming tutorial presented in an easy-to-follow manner. Each web programming tutorial has all the practical examples with web programming script and screenshots available.For Angularjs routeprovider pass parameters to controller Example
AngularJS Routing Syntax
https://infinityknow.com/index.html#ShowEvent
https://infinityknow.com/index.html#DisplayEvent
https://infinityknow.com/index.html#DeleteEvent
var appvar = angular.module("yourappsname", ['ngRoute']); appvar.config(function($routeProvider) { $routeProvider .when('/viewpage1', { templateUrl: 'viewpage1.html', controller: 'myFirstlevelController' }) .when('/view2', { templateUrl: 'viewpage2.html', controller: 'mySecondlevelController' }) .otherwise({ redirectTo: '/viewpage1' }); });
<title>angularjs routeprovider pass parameters to controller</title> <a href="http://angular.min.js">http://angular.min.js</a> <a href="http://angular-route.js">http://angular-route.js</a> <p><a href="#/">Main</a></p> <a href="#Home">Home</a> <a href="#About">About</a> <a href="#Contact">Contact</a> <div></div> var wapp = angular.module("infinityknow", ["ngRoute"]); wapp.config(function($routeProvider) { $routeProvider .when("/", { templateUrl : "index.htm" }) .when("/Home", { templateUrl : "Home.htm" }) .when("/About", { templateUrl : "About.htm" }) .when("/Contact", { templateUrl : "Contact.htm" }); }); <p>Simple Click on the all the links to navigate to "Home.htm", "About.htm", "Contact.htm", or back to "main.htm"</p>
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:
Route Parameters
#/route1/productid
angularjs routeprovider pass parameters to controller
Here is a very simple full example of AngularJS route with parameter example:
<title>AngularJS Routes with parameters example</title> <a href="http://angular.min.js">http://angular.min.js</a> <a href="http://angular-route.min.js">http://angular-route.min.js</a> <a href="#/route1/abcd">click to Route 1 + parameter</a><br /> <a href="#/route2/1234">click to Route 2 + parameter</a><br /> <div></div> var mywApp = angular.module("infinityknowApp", ['ngRoute']); mywApp.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/route1/:param', { templateUrl: 'angularpost1.html', controller: 'MyfirstroutCtrl' }). when('/route2/:param', { templateUrl: 'angularpage.html', controller: 'MyfirstroutCtrl' }). otherwise({ redirectTo: '/' }); }]); mywApp.controller("MyfirstroutCtrl", function($scope, $routeParams) { //store in param variable to parameters $scope.param = $routeParams.param; })
We hope you get an idea about Angularjs routeprovider pass parameters to controller
We would like to have feedback on my Information blog .
Your valuable any feedback, Good question, Inspirational Quotes, or Motivational comments about this article are always welcome.
If you liked this post, Please don’t forget to share this as Well as Like FaceBook Page.
We hope This Post can help you…….Good Luck!.