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

  • Home
  • SEARCH
  • 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 8204089
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:47:07+00:00 2026-06-07T07:47:07+00:00

I start with code: when(‘/admin’, { templateUrl: ‘partials/admin/layout.html’, controller: AdminCtrl }) when(‘/admin/products’, { templateUrl:

  • 0

I start with code:

when('/admin', {
    templateUrl: 'partials/admin/layout.html',
    controller: AdminCtrl
})
when('/admin/products', {
    templateUrl: '????',
    controller: AdminProductsCtrl
})

Template “tree”:

index.html ---> <div ng-view/>
---layout.html ---> <div ng-include=menu/> and <div ng-include=body/>
------menu.html 
------products.html 

Actually I do this:

function AdminCtrl($scope) {
     $scope.menu = 'partials/admin/menu.html';
}

function AdminProductsCtrl($scope) {
    $scope.menu = 'partials/admin/menu.html';
    $scope.body = 'partials/admin/products/index.html';
}

The point is: What I put in ‘????’, if I put layout.html this work fine, but I like just “refresh” ng-include=body. I think that my concepts about Angularjs is wrong.

Other problem is, when AdminProductsCtrl “take the control” of layout.html I miss the AdminCtrl $scope, this implicates repeat all AdminCtrl $scope in AdminProductsCtrl $scope (for example $scope.menu).

Thanks a lot, and sorry for “my english”.

UPDATE

After think.. and think… I understanding that routes not apply for my app, then I manage all functionality under one url ‘site.com/#/admin’. The menu.html is manage for AdminMenuCtrl, this controller contains a model for each ‘ng-include’ and contains one method for each menu entry. When the user click a menu entry, the associate method in the $scope replace $scope.includes.body with the ‘new’ html. The partial cointains your ng-controller.

This works fine by now :D. And the best is that I don’t need use $rootScope.

The new problem is a bit more complicated, the ng-include require a tag (i.e DIV) and ng-controller too. Then my design is affected for this. In code language:

DESING:

<div>MENU-HTML</div>
<div>BODY-HTML</div>

TEMPLATE:

<div ng-include="menu"></div>
<div ng-include="body"></div>

AFTER RETRIEVE PARTIALS:

<div ng-include="menu"><div ng-controller="MenuCtrl">MENU-HTML</div></div>
<div ng-include="body"><div ng-controller="ListProductsCtrl">BODY-HTML</div></div>

THE IDEAL THING:

1 – ng-include don’t ‘include’ into the DIV, instead ‘replace’ the DIV.

2 – ng-controller DIV is replaced for nothing in the DOM.

It’s possible now with angular? Is a bad approach this idea? The point 2 with $route is possible, not with ng-controller directive.

  • 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-07T07:47:09+00:00Added an answer on June 7, 2026 at 7:47 am

    I believe you are correct in your example you would set ???? to layout.html but the idea is to have different views based on the route so pointing to the same layout.html is not ideal.

    If you are trying to keep a static menu on all pages I would add the menu to your index.html and then choose a different templateUrl for each route (ie /admin goes to partials/admin.html and /admin/products goes to partials/products.html) and not use the ngInclude.

    I’m new to AngularJS but I’m getting the impression that you generally want to use ngView with routes to templateUrls OR use ngInclude (possibly with ngSwitch) if you want to roll your own view switching. I’m sure there are times when using both is appropriate but as a newbie it confuses me somewhat. Resident experts please correct me if I’m wrong!

    For your second issue there might be some helpful information here and here for tips on sharing the same model across multiple controllers but you probably don’t need to for your example.

    An alternative is to use a string constant path to your partial in layout.html and remove the references to $scope.menu in your controller code by using:

    <div ng-include="'partials/admin/menu.html'"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's start with code: <html> <head> <title>Opera bug test</title> <script type=text/javascript> function callTest() {
I recently updated to the new version of XCode and the session start code
I would like to start making code patches to Rails. Are there any good
I would like to know how to start and code a thread manager for
I am newbie. many of javascript code start with <!-- <script type=text/javascript> <!-- and
I am a very proficient C# developer, but need to start writing code that
I need start off with code because I am not sure what terminology to
I have the following code TransitionManager.start(babyPreloader,{type:Fade, direction:Transition.OUT, duration:0.5, easing:Regular.easeOut}); var tempPreloader:DisplayObject = babyPreloader as
This is my code to start a process in Windows via java (and gobble
I would expect the following code to start my slider at '30' in it's

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.