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 9323797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:26:03+00:00 2026-06-19T04:26:03+00:00

Is it possible to nest ng-switch-when insides of ng-repeat ? <div ng-controller=UserController> <div ng-switch

  • 0

Is it possible to nest ng-switch-when insides of ng-repeat?

<div ng-controller="UserController">
                            <div ng-switch on="renderPath">
                                <div ng-repeat="route in routes">
                                    <div ng-switch-when="route.path">
                                        <div ng-include src="route.url"></div>
                                    </div>
                                </div>
                            </div>
                        </div>

I got the following exception when I run it:

    Error: Argument '?' is required
pa@http://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.min.js:16 ...

<!-- ngSwitchWhen: route.path -->

Thank you!

EDIT

What I am trying to accomplish is the following

<div ng-switch on="renderPath">
                                    <div ng-switch-when="path1">
                                        <div ng-include src="url1"></div>
                                    </div>
                                    <div ng-switch-when="path2">
                                        <div ng-include src="url2"></div>
                                    </div>
                                    <div ng-switch-when="path3">
                                        <div ng-include src="url3"></div>
                                    </div>
                                </div>
                            </div>

So I was wondering if I can use ng-repeat to help ne reduce the redundant HTML template code (ng-switch-when) above.

  • 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-19T04:26:05+00:00Added an answer on June 19, 2026 at 4:26 am

    No you can’t nest them. ng-switch adds an entry to the $$watchers array on the ng-controller $scope. ng-repeat creates a new child scope for each iteration. When ng-switch-when is encountered, (I’m guessing here) it can’t find any ng-switch information in the current $scope (which is now the ng-repeat child scope), so it fails.

    Update: I looked into this some more. The error happens with 1.0.3, but not 1.0.4 (but it doesn’t work with 1.0.4 either). What is actually going on is that the ng-switch-when scope is a child scope of the controller’s scope, not the ng-repeat iteration child scope. Therefore, route is not visible to the ng-switch-when directives. Here’s a fiddle that uses 1.0.4 — you can click some links to see the controller, ng-repeat, and ng-switch-default scopes. Examining the ng-switch-default scope, you can see that its $parent is the controller’s scope, not an ng-repeat scope.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible and valid to nest a <div> tag inside an <li> tag
Is it possible to nest selectors within selectors? I have a lot of styles
Is it possible to nest simple programs within a Google Sheets, similar to how
Is it possible to use the C preprocessor to nest goto labels in C11
I'd like to know if it is possible in Java to nest Enums. Here
Using a C# 3.5 Winforms - Is it possible to nest one listview inside
In Python, it is possible to nest functions like this: def do_something(): def helper():
Possible Duplicate: How to nest OR statements in JavaScript? Is there a way to
Is it possible to nest multiple settings.gradle files for a multi module project? E.g.
Is it possible to nest a singleton class inside a non-singleton class in C#,

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.