Angularjs routeprovider pass parameters to controller

Rate this post

Angularjs routeprovider pass parameters to controller

Today, We want to share with you Angularjs routeprovider pass parameters to controller.
In this post we will show you Angularjs routeprovider pass parameters to controller, hear for Angularjs routeprovider pass parameters to controller we will give you demo and example for implement.
In this post, we will learn about Angularjs routeprovider pass parameters to controller with an example.

The ngRoute module in angular to helps your web-application to become a website for a Single Page Application.and The ngRoute simple module routes your web-application to all the different pages or tpl page without any way to reloading the entire each web-application.

READ :  Angularjs Multiple Image Slider - Thumbnails Slider Example

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 routeparams in controller

app.js
[php]
‘use strict’;
// Declare all the app level module which depends on filters, and services
var app= angular.module(‘myApp’, [‘ngRoute’,’ngAnimate’,’ngSanitize’,’ui.bootstrap’, ‘ui.select’,’ngTouch’,’ui.grid’, ‘ui.grid.edit’,’ui.select’,’ui.grid.pagination’,’addressFormatter’,’angularUtils.directives.dirPagination’,’angular-loading-bar’,’infinityknowAPI’,’addressFormatter’]);

app.config([‘cfpLoadingBarProvider’, function (cfpLoadingBarProvider) {
cfpLoadingBarProvider.includeSpinner = false;
}]);
app.config([‘$routeProvider’, function($routeProvider) {
$routeProvider.when(‘/login’, {templateUrl: ‘partials/login.html’, controller: ‘loginCtrl’});
$routeProvider.when(‘/home’, {templateUrl: ‘partials/home.html’, controller: ‘homeCtrl’});
$routeProvider.when(‘/salesnew’, {templateUrl: ‘partials/salesnew.html’, controller: ‘salesnewCtrl’});
$routeProvider.when(‘/salesview’, {templateUrl: ‘partials/salesview.html’, controller: ‘salesviewCtrl’});
$routeProvider.when(‘/kivlistview’, {templateUrl: ‘partials/kivlistview.html’, controller: ‘kivlistviewCtrl’});
$routeProvider.when(‘/users’, {templateUrl: ‘partials/users.html’, controller: ‘usersCtrl’});
$routeProvider.when(‘/forgot’, {templateUrl: ‘partials/forgot.html’, controller: ‘forgotCtrl’});
$routeProvider.otherwise({redirectTo: ‘/login’});
}]);

READ :  Angular form ng submit Directive

app.run(function($rootScope, $location, loginService){
var routespermission=[‘/home’]; //route that require login
var salesnew=[‘/salesnew’];
var salesview=[‘/salesview’];
var kivlistview=[‘/kivlistview’];
var users=[‘/users’];
$rootScope.$on(‘$routeChangeStart’, function(){
if( routespermission.indexOf($location.path()) !=-1
|| salesview.indexOf($location.path()) !=-1
|| kivlistview.indexOf($location.path()) !=-1
|| salesnew.indexOf($location.path()) !=-1
|| users.indexOf($location.path()) !=-1)
{
var connected=loginService.islogged();
connected.then(function(msg){
if(!msg.data)
{

$location.path(‘/login’);
}

});

}
init();
});
});

angular.module(‘addressFormatter’, []).filter(‘address’, function () {
return function (input) {
return input.street + ‘, ‘ + input.city + ‘, ‘ + input.state + ‘, ‘ + input.zip;
};
});

[/php]

index.html
[php]

infinityknow Web Ordering

http://angular.js
http://lib/angular/angular-route.js
http://js/app.js
http://js/select.js
http://js/directives/loginDrc.js
http://js/controllers/loginCtrl.js
http://js/controllers/homeCtrl.js
http://js/controllers/salesnewCtrl.js
http://js/controllers/salesviewCtrl.js
http://js/controllers/kivlistviewCtrl.js
http://js/controllers/usersCtrl.js
http://js/infinityknowAPI.js

[/php]

Example

angularjs routeparams in controller | angularjs routeprovider example | angularjs get url parameters |

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.

READ :  VueJS Installation and Configuration - VueJS Environment Setup

We hope This Post can help you…….Good Luck!.

Leave a Reply

Your email address will not be published.