我如何在AngularJS设置嵌套的看法? [英] How do I setup nested views in AngularJS?

查看:189
本文介绍了我如何在AngularJS设置嵌套的看法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有各种各样的屏幕的应用程序的。每个屏幕都分配有一个网址,如邮件联系人,等等。

I have an application with various screens. Each screen is assigned a URL, such as #, mails, contacts, and so on.

在我的主HTML文件我有一个 NG-视图元素根据路由用户选择的更新。到目前为止,一切都很好。

In my main HTML file I have an ng-view element which updates according to the route the user selects. So far, so good.

现在一些屏幕有一个子导航。例如, #mails 确实有一个收件箱和发送的文件夹。它们present themselfes有两列:左侧的子导航,在右侧的相应文件夹的邮件

Now some of these screens have a sub-navigation. E.g., #mails does have an inbox and a sent folder. They present themselfes with two columns: The sub-navigation on the left, the mails of the appropriate folder on the right.

当您导航到 #mails ,应当重定向到#邮件/收件箱,所以,基本上收件箱的是默认的子视图邮件。

When you navigate to #mails, it shall redirect you to #mails/inbox, so that basically inbox is the default sub-view for mails.

我怎么能设置呢?

目前,我能想到的唯一的方法(我很新的AngularJS,所以原谅我,如果这个问题有点幼稚)是有两种观点,一个是#邮件/收件箱,另一个用于#邮件/发送

The only approach I can currently think of (I am quite new to AngularJS, hence forgive me if this question is a little bit naive) is to have two views, one for #mails/inbox, and the other for #mails/sent.

当你选择的路线,这些意见被加载。当您选择 #mails 它只是将您重定向到#邮件/收件箱

When you select a route, these views are loaded. When you select #mails it simply redirects you to #mails/inbox.

但是,这意味着这两种观点必须使用 NG-包括的子导航。不知怎的,这感觉我错了。

But this means that both views must use an ng-include for the sub-navigation. Somehow this feels wrong to me.

我想更多的是嵌套的看法:屏幕之间的顶部有一个开关,如邮件,联系人等,而子视图,如收件箱,发间的底面合一的变化,等等。

What I'd like more is to have nested views: The top one switches between screens such as mails, contacts, and so on, and the bottom one changes between sub-views such as inbox, sent, and so on.

我将如何解决这个问题?

How would I solve this?

推荐答案

AngularJS UI路由器解决了我的问题: - )

AngularJS ui-router solved my issues :-)

这篇关于我如何在AngularJS设置嵌套的看法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆