multiple views in single page

3,652 views
Skip to first unread message

Wes Jones

unread,
Dec 27, 2011, 4:32:40 PM12/27/11
to ang...@googlegroups.com
I almost had your framework working with an application in which we could cross over and have the same controllers for mobile and desktop version of the application. However, 2 problems that I cannot seem to work around in your framework and I am hoping you have an idea of something I have overlooked.

I was going to do nested controllers, but couldn't get the inheritance that I needed because constructors are not fired the prototype is copied to another object. So I loose any base functionality on those controller classes.

That would be a mute point if I could support multiple deep linking with views. For example a dashboard.
On a mobile device you would only show one route at a time, which works great. However, on a desktop I show as many as for views on the page at the same time. Which doesn't allow me to switch out each of those template areas based on a route change and maintain the same top level template. I am all ears if you have any suggestions to accomplish this.

Really I am trying to find a way to minimize my code maintenance between mobile and desktop versions of the same applications.

--
Wes Jones
Codeguyz
P.O. Box 36 Honeyville, UT 84314

Vojta Jina

unread,
Dec 27, 2011, 7:01:33 PM12/27/11
to ang...@googlegroups.com
Hey Wes,

I'm not sure I follow your problem.

1/ nesting controllers - you're right, we copied methods from prototype, but we apply the constructor as well, which functionality do you loose ?
We are going to separate controller from scope (inject scope into controller and instantiate contrllers properly, using new operator) - this change is already done, should be merged into master soon. But anyway, even with current state I can't see what are you loosing ?

2/ multiple views
Again, not sure I follow - do you mean having multiple ng:views on one page ? That's current limitation of ng:view, which we are aware and will solve.
In meantime, you can implement the same functionality with ng:include, you can even have nested ng:includes and determine the template based on the url (which might be nested as well, ie. /some/:firstPageId/:subPageId

V.

Charlie

unread,
Feb 24, 2012, 5:37:25 PM2/24/12
to AngularJS

Are there any examples of nested ng:includes available?

Thanks,
Charlie

Vojta Jina

unread,
Feb 26, 2012, 12:29:34 AM2/26/12
to ang...@googlegroups.com
Hey Charlie,

I remember some jsfiddle example with nested ng:includes, please try to search archive of mailing list.

Do you have any problem with nesting ng:include ? Should just work...

V.

Stephane Bisson

unread,
Feb 26, 2012, 6:51:24 AM2/26/12
to AngularJS
Here's an example of how it can be done (hosted in gh-pages):

http://stephanebisson.github.com/layout/

I have used a recent angular build because I wanted to use inline
templates instead of external partial files.

I am not sure it's a good way of doing this. Feedback is welcome ;)

cheers
stephane

Charlie

unread,
Feb 26, 2012, 5:30:22 PM2/26/12
to AngularJS
Thanks Vojta and Stephane,
I have looked at a ton of examples, part of the problem is that many
of the examples break when you upgrade the version of Angular :-(

I think I'll try Stephane's approach but I need to migrate my widgets
over to directives, when I try to upgrade to 10.7 from 10.6 Angular is
not happy.

-Charlie

On Feb 26, 6:51 am, Stephane Bisson <stephane.c.bis...@gmail.com>
wrote:

Charlie

unread,
Feb 27, 2012, 1:29:36 PM2/27/12
to AngularJS
Thanks Stephane!
I moved the script declarations out into external files and everything
still works beautifully and is exactly what I am looking for.

-Charlie

Charlie

unread,
Feb 28, 2012, 8:40:39 AM2/28/12
to AngularJS
Stephane,
How would I assign a controller to the nested templates?
I'm still struggling with the changes to scope in 10.7.

http://jsfiddle.net/cfulnecky/4uGR6/

On Feb 27, 1:29 pm, Charlie <cfulne...@gmail.com> wrote:
> Thanks Stephane!
> I moved the script declarations out into external files and everything
> still works beautifully and is exactly what I am looking for.
>
> -Charlie
>
> On Feb 26, 5:30 pm, Charlie <cfulne...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Thanks Vojta and Stephane,
> > I have looked at a ton of examples, part of the problem is that many
> > of the examples break when you upgrade the version of Angular :-(
>
> > I think I'll try Stephane's approach but I need to migrate my widgets
> > over to directives, when I try to upgrade to 10.7 from 10.6 Angular is
> > not happy.
>
> > -Charlie
>
> > On Feb 26, 6:51 am, Stephane Bisson <stephane.c.bis...@gmail.com>
> > wrote:
>
> > > Here's an example of how it can be done (hosted in gh-pages):
>
> > >http://stephanebisson.github.com/layout/
>
> > > I have used a recent angular build because I wanted to use inline
> > > templates instead of external partial files.
>
> > > I am not sure it's a good way of doing this. Feedback is welcome ;)
>
> > > cheers
> > > stephane
>
> > > On Feb 26, 1:29 pm, Vojta Jina <vojta.j...@gmail.com> wrote:
>
> > > > Hey Charlie,
>
> > > > I remember some jsfiddle example withnestedng:includes, please try to
> > > > search archive of mailing list.
>
> > > > Do you have any problem with nesting ng:include? Should just work...

Stephane Bisson

unread,
Feb 29, 2012, 8:06:25 AM2/29/12
to AngularJS
Hey Charlie,

here's an updated version of your fiddle:
http://jsfiddle.net/stephanebisson/QpP65/2/

I changed the jsfiddle config to be "no wrap (body)" instead of
"onDomReady". That fixes your bindings.

I have also removed
this.scope = $scope;
this.message = "something";
from your controllers.

In 0.10.7, the keyword "this" inside a controller doesn't mean much.
Anything that you would have assign to "this" before you now have to
assign to the injected $scope. In other words, you put $scope.message
= "FOO"; in your controller and {{message}} in your view and the magic
should happen.

As for the controller in a nested template, I think you got it right
by adding ng:controller inside your template. I have wired the layout
controllers using the same approach in your fiddle. It could be made
more "dynamic" by instantiating the controller and passing it to the
scope property of the ng:include that is loading your layout but with
the new separation between scope and controller I am not sure it makes
sense.

hope it helps

stephane

Charlie

unread,
Feb 29, 2012, 9:25:39 AM2/29/12
to AngularJS
Perfect! Thanks again Stephane :-)

On Feb 29, 8:06 am, Stephane Bisson <stephane.c.bis...@gmail.com>
Message has been deleted

Cary

unread,
May 25, 2012, 11:56:15 PM5/25/12
to ang...@googlegroups.com
Vojta,

Has the multiple ng:views issue been resolved?  This really is an important feature.


Thank you very much,
Cary

Vojta Jína

unread,
Jun 13, 2012, 2:04:30 AM6/13/12
to ang...@googlegroups.com
Not yet. We wanna do nested views, but it's not super high priority now.
Use ng-include, you can achieve the same thing with it, it will only require some coding...

V.

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/vREaDe9vLHwJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Vojta Jína

unread,
Jun 13, 2012, 2:04:46 AM6/13/12
to ang...@googlegroups.com
And of course, pull requests are welcomed :-D

Gerhard Hipfinger

unread,
Aug 23, 2012, 7:53:52 PM8/23/12
to ang...@googlegroups.com
Hi Stephane,

is this still the way to go in 1.0.1?

I was not able to bring this to work. I did change $beforeRouteChange to $routeChangeStart as well as setting up the routes via $routeProvider in the module config block as described in the changelog.

Is someone else having the same issue?

Thanx,
Gerhard
Reply all
Reply to author
Forward
0 new messages