user1167650
user1167650

Reputation: 3207

Can you have Nested ngView in angularjs?

I have a single-page web app whose template/webpage looks like:

[templateLeft | templateRight]

I want to setup routes such that when some user is not logged in, they go to a different page (a login page), and when they are logged in, routes only effect templateRight (such that templateLeft isn't reloaded).

It seems like the best way to do this is using routing and ng-view, but since one route effects the entire page and one route effects only templateRight, I'm not sure how to go about creating the controllers / routes properly because it seems like you can't have nested ng-view's.

Am I wrong? What's a good way to achieve this?

Upvotes: 3

Views: 1658

Answers (2)

pkozlowski.opensource
pkozlowski.opensource

Reputation: 117370

There is no standard way of having nested ngView with the current version of AngularJS. This is quite common request and there are some pull requests opened for this but nothing checked-in.

There were several discussion about this topic both on the mailing list and SO and people were trying to employ different strategies but once again - there is no clean / recommended way of having nested ngView.

Recently the AngularJS team recognized that there is room for multiple routers and refactored the routing service (and the ngView directive) out of the core into a separate module. The most promising, community-drive effort to replace the "official" router seems to be angular-ui router: https://github.com/angular-ui/router

Upvotes: 2

AngryTux
AngryTux

Reputation: 41

Actually, there is an Alpha development on-going available here : https://github.com/angular-ui/ui-router

Main Goal To evolve the concept of an Angular "Route" into a more general concept of a "State" for managing coarse application UI states.

Main Features: A state manager $stateProvider and $state, keeps state logic separate from routing logic. Nested states (parent/child relationships). Can set multiple views via named views. ui-view directive. URL Routing Backwards compatible with Angular v1 router Various other nuggets of goodness

Upvotes: 3

Related Questions