Multiple ng:view on the same page.

已查看 25,579 次
跳至第一个未读帖子

Khurram

未读,
2011年9月14日 06:54:392011/9/14
收件人 AngularJS
To build my next app I'm evaluating a number of JS frameworks and
AngularJS scores higher than any other framework.
I would like ask a number of design question.

1. Can we use multiple <ng:view> on the same page to render different
partials on different <ng:view> tags. For example If an app where
Parent menu item renders a partial in <ng:view> tag. The partial
itself has a number of navigation links and each needs to be open in
their own ng:view tags.

2. What is the best way for Inter-Controller communication. For
example if UserController wants to dispatch an UpdateUser event to
ProductController, what is the standard way in AngularJS. (kind of
observer pattern)

Misko Hevery

未读,
2011年9月14日 13:52:402011/9/14
收件人 ang...@googlegroups.com
See inline

On Wed, Sep 14, 2011 at 3:54 AM, Khurram <teg...@gmail.com> wrote:
To build my next app I'm evaluating a number of JS frameworks and
AngularJS scores higher than any other framework.
I would like ask a number of design question.

1. Can we use multiple <ng:view> on the same page to render different
partials on different <ng:view> tags. For example If an app where
Parent menu item renders a partial in <ng:view> tag. The partial
itself has a number of navigation links and each needs to be open in
their own ng:view tags.

<ng:view> is tied to $resource, and right now you can only have one. But you can have as many <ng:includes> as you want, but you have to do the wiring yourself.
 

2. What is the best way for Inter-Controller communication. For
example if UserController wants to dispatch an UpdateUser event to
ProductController, what is the standard way in AngularJS. (kind of
observer pattern)

Turn your long lived data into a service and inject it into the controllers.
 

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
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.


Witold Szczerba

未读,
2011年9月14日 14:47:162011/9/14
收件人 ang...@googlegroups.com
See inline:

On 14 September 2011 19:52, Misko Hevery <mi...@hevery.com> wrote:
> On Wed, Sep 14, 2011 at 3:54 AM, Khurram <teg...@gmail.com> wrote:
>>
>> 1. Can we use multiple <ng:view> on the same page to render different
>> partials on different <ng:view> tags. For example If an app where
>> Parent menu item renders a partial in <ng:view> tag. The partial
>> itself has a number of navigation links and each needs to be open in
>> their own ng:view tags.
>
> <ng:view> is tied to $resource, and right now you can only have one. But you
> can have as many <ng:includes> as you want, but you have to do the wiring
> yourself.

Little correction: <ng:view> is tied to $route, not $resource.
As to wiring - it is very straightforward in Angular :)

Regards,
Witold Szczerba

Khurram

未读,
2011年9月14日 15:16:272011/9/14
收件人 AngularJS
I dont get your reply.

I know the basic functionality of $route and <ng:view>.

I'm curious how we can use two different <ng:view> on the same page to
load two different partials.

Witold Szczerba

未读,
2011年9月14日 15:29:172011/9/14
收件人 ang...@googlegroups.com
That is the point: as Misko said - you cannot use <ng:view> for that,
use <ng:include> instead.

Magrelo

未读,
2011年9月14日 16:40:412011/9/14
收件人 AngularJS
You can have a <ng:include src="bind_to_url"></ng:include> that binds
to a variable on your controller. Then you can change this variable as
you want.


Thiago

Igor Minar

未读,
2011年9月14日 23:39:502011/9/14
收件人 ang...@googlegroups.com
right, but we will support multiple ng:views per $route definition. check back in a few weeks.

/i

ItsLeeOwen

未读,
2012年4月13日 22:09:072012/4/13
收件人 ang...@googlegroups.com
Has this feature been implemented?  In this example, I'm looking to route specific urls/templates to specific ng-views







Igor Minar

未读,
2012年4月14日 01:48:302012/4/14
收件人 ang...@googlegroups.com
no. not yet. I experimented with it a bit but it got quite complicated and we decided to put on it for 1.0.

We do want the routing to be more sophisticated, it's just not going to happen for 1.0

/i

On Fri, Apr 13, 2012 at 7:09 PM, ItsLeeOwen <l...@coderebelbase.com> wrote:
Has this feature been implemented?  In this example, I'm looking to route specific urls/templates to specific ng-views




--
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/-/d_FhDCmhXdUJ.

Söderlind

未读,
2012年4月14日 11:23:022012/4/14
收件人 ang...@googlegroups.com
Try this:  http://jsfiddle.net/johaa1993/xsbWd/2/

Use it with ng-include. Note that you can check if its a number by using regexp or a text or whatever(*).

Cary

未读,
2012年5月6日 16:34:152012/5/6
收件人 ang...@googlegroups.com
Igor - this is really a necessary feature.  What's your ETA on supporting multiple views for routing?


On Saturday, April 14, 2012 12:48:30 AM UTC-5, Igor Minar wrote:
no. not yet. I experimented with it a bit but it got quite complicated and we decided to put on it for 1.0.

We do want the routing to be more sophisticated, it's just not going to happen for 1.0

/i

On Fri, Apr 13, 2012 at 7:09 PM, ItsLeeOwen <l...@coderebelbase.com> wrote:
Has this feature been implemented?  In this example, I'm looking to route specific urls/templates to specific ng-views







--
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/-/d_FhDCmhXdUJ.

To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.
/i

To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.
/i

To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.
/i

To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.

Cary

未读,
2012年5月6日 16:36:372012/5/6
收件人 ang...@googlegroups.com
Söderlind - can you fix your JSFiddle link?  I'd like to take a look.
Thanks

carste...@gmail.com

未读,
2012年7月2日 13:22:532012/7/2
收件人 ang...@googlegroups.com
First of all: congrats on the framework and the 1.0 release!

We do want the routing to be more sophisticated
Are you thinking roughly in this kind of direction? Looks promising...

it's just not going to happen for 1.0
Really just my 2 cents, but: may I suggest to then take the feature out of angular-seed until you're done?
Like I just did, angular-seed is probably one of the first places people get their hands dirty with, when using Angular the first time.
The usage of route/view there then makes one think that views are a root concept in angular and really the next question that comes to mind, is how to multiply/nest views, then.

On Saturday, April 14, 2012 7:48:30 AM UTC+2, Igor Minar wrote:
no. not yet. I experimented with it a bit but it got quite complicated and we decided to put on it for 1.0.

We do want the routing to be more sophisticated, it's just not going to happen for 1.0

/i

On Fri, Apr 13, 2012 at 7:09 PM, ItsLeeOwen <l...@coderebelbase.com> wrote:
Has this feature been implemented?  In this example, I'm looking to route specific urls/templates to specific ng-views







--
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/-/d_FhDCmhXdUJ.

To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.

numan

未读,
2012年8月3日 21:02:532012/8/3
收件人 ang...@googlegroups.com
Hi Igor, now that 1.0 is out, is this feature in there or has it been moved to later releases?



On Saturday, April 14, 2012 1:48:30 AM UTC-4, Igor Minar wrote:
no. not yet. I experimented with it a bit but it got quite complicated and we decided to put on it for 1.0.

We do want the routing to be more sophisticated, it's just not going to happen for 1.0

/i

On Fri, Apr 13, 2012 at 7:09 PM, ItsLeeOwen <l...@coderebelbase.com> wrote:
Has this feature been implemented?  In this example, I'm looking to route specific urls/templates to specific ng-views







--
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/-/d_FhDCmhXdUJ.

To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+unsubscribe@googlegroups.com.

war...@gmail.com

未读,
2012年8月4日 06:45:222012/8/4
收件人 ang...@googlegroups.com
Really interested too.

roytr...@gmail.com

未读,
2012年8月17日 15:04:522012/8/17
收件人 ang...@googlegroups.com、war...@gmail.com
+1

ebeltr...@gmail.com

未读,
2012年10月25日 16:16:222012/10/25
收件人 ang...@googlegroups.com
+1

Partap Davis

未读,
2012年10月25日 19:49:152012/10/25
收件人 ang...@googlegroups.com、ebeltr...@gmail.com
+1

On Thursday, October 25, 2012 1:16:22 PM UTC-7, ebeltr...@gmail.com wrote:
+1

peter....@gmail.com

未读,
2012年11月1日 08:34:072012/11/1
收件人 ang...@googlegroups.com
Is there any progress on supporting multiple views bound to the routing path? The workaround using ng-controller, manually parsing the routing path and binding the template via ng-include seems very cumbersome, if it works at all... 


On Sunday, May 6, 2012 10:34:15 PM UTC+2, Cary Landholt wrote:
Igor - this is really a necessary feature.  What's your ETA on supporting multiple views for routing?

On Saturday, April 14, 2012 12:48:30 AM UTC-5, Igor Minar wrote:
no. not yet. I experimented with it a bit but it got quite complicated and we decided to put on it for 1.0.

We do want the routing to be more sophisticated, it's just not going to happen for 1.0

/i

On Fri, Apr 13, 2012 at 7:09 PM, ItsLeeOwen <l...@coderebelbase.com> wrote:
Has this feature been implemented?  In this example, I'm looking to route specific urls/templates to specific ng-views







--
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/-/d_FhDCmhXdUJ.

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.

On Saturday, April 14, 2012 12:48:30 AM UTC-5, Igor Minar wrote:
no. not yet. I experimented with it a bit but it got quite complicated and we decided to put on it for 1.0.

We do want the routing to be more sophisticated, it's just not going to happen for 1.0

/i

On Fri, Apr 13, 2012 at 7:09 PM, ItsLeeOwen <l...@coderebelbase.com> wrote:
Has this feature been implemented?  In this example, I'm looking to route specific urls/templates to specific ng-views







--
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/-/d_FhDCmhXdUJ.

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.

On Saturday, April 14, 2012 12:48:30 AM UTC-5, Igor Minar wrote:
no. not yet. I experimented with it a bit but it got quite complicated and we decided to put on it for 1.0.

We do want the routing to be more sophisticated, it's just not going to happen for 1.0

/i

On Fri, Apr 13, 2012 at 7:09 PM, ItsLeeOwen <l...@coderebelbase.com> wrote:
Has this feature been implemented?  In this example, I'm looking to route specific urls/templates to specific ng-views







--
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/-/d_FhDCmhXdUJ.

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.

On Saturday, April 14, 2012 12:48:30 AM UTC-5, Igor Minar wrote:
no. not yet. I experimented with it a bit but it got quite complicated and we decided to put on it for 1.0.

We do want the routing to be more sophisticated, it's just not going to happen for 1.0

/i

On Fri, Apr 13, 2012 at 7:09 PM, ItsLeeOwen <l...@coderebelbase.com> wrote:
Has this feature been implemented?  In this example, I'm looking to route specific urls/templates to specific ng-views







--
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/-/d_FhDCmhXdUJ.

To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.

dlpor...@gmail.com

未读,
2012年12月9日 12:23:012012/12/9
收件人 ang...@googlegroups.com
I've been exploring angular got a grew days note Anne think it is very promising. However, until it supports multiple ng-views, I cannot seriously consider it for enterprise application.

Waiting with bated breath for this feature.

Thanks for ask you're work.

dlpor...@gmail.com

未读,
2012年12月9日 12:26:162012/12/9
收件人 ang...@googlegroups.com
I've been exploring angular for a few days now and think it is very promising. However, until it supports multiple ng-views, I cannot seriously consider it for enterprise application development.

Waiting with bated breath for this feature.

Thanks for all you're work.

Ignore the previous post

Michael Bielski

未读,
2012年12月10日 11:01:572012/12/10
收件人 ang...@googlegroups.com、dlpor...@gmail.com
I've been using Angular for several months now and found that I can get along just fine with only one ng-view on the page. Using ng-include as Misko suggested works very well and makes it easier to have things like navigation in a single file that can be updated once and propagated through the entire application. When you add in the ability to change what is referenced by an ng-include programmatically, the possibilities are now endless. For example:

<div ng-include="template" id="modalContainer" class="modal fade">
</div>

Now you can simply change the value of "template" and control what goes into your modal. Set "template" to a URL and tell the modal to show. Viola! Content that was loaded on-the-fly! When you're done, tell the modal to close and then clear the value of "template". Poof! It's gone! The whole thing is lightweight and flexible, just like Angular apps should be.

Maxence Warzecha

未读,
2012年12月10日 11:33:492012/12/10
收件人 ang...@googlegroups.com、dlpor...@gmail.com
After several months working with Angular, I don't feel the need of mutliple ng-view anymore. I think that it may help but not so important after all (at least in my case!).


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.



--
Maxence Warzecha | - 120, rue Dupont des Loges | F-57100 Thionville

Cary Landholt

未读,
2012年12月10日 22:46:582012/12/10
收件人 ang...@googlegroups.com、dlpor...@gmail.com
Like some of the others have commented, at first I thought this would be a really big pain.  But working with Angular for several months, I've not had a problem.

edwardt...@gmail.com

未读,
2013年1月10日 12:12:212013/1/10
收件人 ang...@googlegroups.com、dlpor...@gmail.com
I would like to use ng-includes to get around the need for multiple (specifically: nested) views. However, I do have a requirement to be able to update the urls accordingly, like when using angular routes. Is there any way to do this?

Bretto

未读,
2013年1月13日 17:59:202013/1/13
收件人 ang...@googlegroups.com、dlpor...@gmail.com、edwardt...@gmail.com
Yes, I had to circumvent this shortcoming too, point your route to a generic partial and a controller,in the partial have an ng-include and point to a property on that scope, in the controller setup that property from the  $routeParams. Does this makes sense ?

Bretto

未读,
2013年1月13日 19:46:202013/1/13
收件人 ang...@googlegroups.com
Partial:

<div id="experiment-wrap" ng-include="'experiment/'+appModel.currentItem.id"/>

Controller:

controllers.controller('ExperimentCtrl', function($scope, $rootScope, $log, AppModel, $routeParams, $location, LAYOUT){

        $scope.appModel.currentItem = getItemById($routeParams.id);
}

Routes:

when('/experiment/:id', {controller:'ExperimentCtrl', templateUrl:'partial/include-experiment'}).


does this help ?


On Wednesday, 14 September 2011 20:54:39 UTC+10, Batman wrote:
To build my next app I'm evaluating a number of JS frameworks and
AngularJS scores higher than any other framework.
I would like ask a number of design question.

1. Can we use multiple <ng:view> on the same page to render different
partials on different <ng:view> tags. For example If an app where
Parent menu item renders a partial in <ng:view> tag. The partial
itself has a number of navigation links and each needs to be open in
their own ng:view tags.

lu...@goonbee.com

未读,
2013年1月31日 09:54:352013/1/31
收件人 ang...@googlegroups.com
I've written a small stateManager which does a kind of very simple "routing" allowing for nested views, deep linking, etc

Dave Merrill

未读,
2013年1月31日 21:58:492013/1/31
收件人 ang...@googlegroups.com
Looks very interesting.

Sorry for the lazy question, but I haven't had a chance to look much at the code, and I see that the repo contains both jQuery and ruby. Are they for the demo and/or build, or are they needed to use this in an app?

Thanks,
Dave

Luka Mirosevic

未读,
2013年2月1日 01:01:082013/2/1
收件人 ang...@googlegroups.com
The ruby code is just to bootstrap the demo (and serve the partials from haml).

In your app all you'd have to do is copy the code of the actual service (the factory method) into your app. It's only about 70 lines iirc. 

Luka
--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to angular+u...@googlegroups.com.

To post to this group, send email to ang...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dave Merrill

未读,
2013年2月1日 07:31:182013/2/1
收件人 ang...@googlegroups.com
Does it require jQuery, or is that also just for the demo?

Thanks,
Dave

Luka Mirosevic

未读,
2013年2月1日 13:33:262013/2/1
收件人 ang...@googlegroups.com
Just for the demo. 

It was actually just used for selecting the title element (once) so I've refactored that to use native js only and remove the jQuery dependency from the demo.

Luka

Dave Merrill

未读,
2013年2月1日 14:44:132013/2/1
收件人 ang...@googlegroups.com
Thanks for clarifying. If it was just for that one thing, removing the dependency's a good idea (:-).

Dave

Allen Emanuel

未读,
2013年7月5日 04:42:192013/7/5
收件人 ang...@googlegroups.com
I too stuck up with this problem and i found Angularjs-ui-router which solve this problem as of now.
回复全部
回复作者
转发
0 个新帖子