在角JS嵌套NG-意见 [英] Nesting ng-views in angular js

查看:120
本文介绍了在角JS嵌套NG-意见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的角度有两个不同的应用程序。在集成到一个单一的应用程序,我不得不

I had two different apps in angular. During integration to a single application I had to

窝NG-意见。

有关样品(的index.html)是

For sample (index.html) is

<!doctype html>
<html lang="en" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>My AngularJS App</title>
<link rel="stylesheet" href="css/app.css"/>
</head>
<body>
<ul class="menu">
<li><a href="#/view1">view1</a></li>
<li><a href="#/view2">view2</a></li>
</ul>

<div ng-view></div>

<div>Angular seed app: v<span app-version></span></div>

<script src="lib/angular/angular.js"></script>
<script src="js/app.js"></script>
<script src="js/services.js"></script>
<script src="js/controllers.js"></script>
<script src="js/filters.js"></script>
<script src="js/directives.js"></script>
</body>
</html>

我的一个应用程序的观点是(view2.html)

One of my app view is (view2.html)

<div class="ng-view"></div>
<p>This is the partial for view 1.</p>
{{ 'Current version is v%VERSION%.' | interpolate }}

现在这个应用程序里面有不同的看法的一次。

Now this application has different views once again inside it.

我试过,但该页面没有加载。有没有一种可能筑巢NG-看法?

I tried but the page is not loading. Is there a possibility to nest ng-views?

如果没有可能可以把它解释

If not Possible can it be explained

在此先感谢

推荐答案

更新的答案:

UI路由器(现在就坐落在这里:的https: //angular-ui.github.io/ui-router/site/#/api/ui.router )被普遍认为是对在AngularJS复杂路由的最佳解决方案。

UI Router (which now sits here: https://angular-ui.github.io/ui-router/site/#/api/ui.router) is generally regarded as the best solution for complex routing in AngularJS.

原来的答复:

嵌套的观点本身并不可能,截至目前,在AngularJS。在我上的应用程序,我用从这里得出一个解决方案:<一href=\"http://www.bennadel.com/blog/2420-Mapping-AngularJS-Routes-Onto-URL-Parameters-And-Client-Side-Events.htm\" rel=\"nofollow\">http://www.bennadel.com/blog/2420-Mapping-AngularJS-Routes-Onto-URL-Parameters-And-Client-Side-Events.htm

Nesting views isn't natively possible, as of now, in AngularJS. In my last app, I used a solution derived from here: http://www.bennadel.com/blog/2420-Mapping-AngularJS-Routes-Onto-URL-Parameters-And-Client-Side-Events.htm

让我有效地窝意见(和完全跳过有限的NG-视图)

Allowing me to effectively nest views (and skipping the limited ng-view altogether)

这样做之后,这个其他(更简单,更好的,我相信)的解决方案出现了:

After doing so, this other (simpler, better, I believe) solution appeared:

http://angular-ui.github.com/ (向下滚动到路径检查)

http://angular-ui.github.com/ (scroll down to "Route Checking")

快来看看吧!

这篇关于在角JS嵌套NG-意见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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