Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8497107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:02:08+00:00 2026-06-11T00:02:08+00:00

Is it possible to pass your own variables in a defined route in AngularJS?

  • 0

Is it possible to pass your own variables in a defined route in AngularJS?

The reason why I’m doing this is because I have to data representations of the same page (one is a filtered view in terms of the JSON data) and all I need to do is give a boolean flag to the $params array to let the controller function know that this page is either filtered or non-filtered.

Something like this:

var Ctrl = function($scope, $params) {
  if($params.filtered) {
    //make sure that the ID is there and use a different URL for the JSON data
  }
  else {
    //use the URL for JSON data that fetches all the data
  }
};

Ctrl.$inject = ['$scope', '$routeParams'];

angular.modlule('App', []).config(['$routeProvider', function($routes) {

  $routes.when('/full/page',{
    templateURL : 'page.html',
    controller : Ctrl
  });

  $routes.when('/full/page/with/:id',{
    templateURL : 'page.html',
    controller : Ctrl,
    params : {
      filtered : true
    }
  });

}]);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:02:12+00:00Added an answer on June 11, 2026 at 12:02 am

    According to $routeProvider documentation, the route parameter of $routeProvider.when() has property resolve:

    An optional map of dependencies which should be injected into the controller.

    Something like this should work:

    function Ctrl($scope, isFiltered) {
      if(isFiltered) {
        //make sure that the ID is there and use a different URL for the JSON data
      }
      else {
        //use the URL for JSON data that fetches all the data
      }
    }
    Ctrl.$inject = ['$scope', 'isFiltered'];
    
    angular.modlule('App', []).config(['$routeProvider', function($routeProvider) {
    
      $routeProvider.when('/full/page',{
        templateURL: 'page.html',
        controller: Ctrl
      });
    
      $routeProvider.when('/full/page/with/:id',{
        templateURL: 'page.html',
        controller: Ctrl,
        resolve: {
          isFiltered: function() { return true; }
        }
      });
    
    }]);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: pass data from Action To Another Action I have a view in
Is it possible to create your own ADDED_TO_STAGE event? I´m trying to pass some
Is it possible to pass *args to string.format? I have the following function: @classmethod
A generally accepted way to pass all data to a view is to have
Is it possible to call a method on the type you pass into your
After reading this question I started to wonder: is it possible to have a
Is it possible to pass a input value of prompt box like this? <script
I have a requirement to pass bulk data between a .NET (c#) application and
Is it possible to specify your own thumbnail for a video that has been
Is it possible to pass arguments to your streaming steps in Amazon EMR? There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.