- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
2015 年 11 月 1 日更新
Aux 路由在 Alpha 45 中并没有得到很好的支持。 Link to Github Issue
支持@evan-plaice
原始问题
我看了 Brian Ford 关于 Angular2 路由器的演讲:https://youtu.be/z1NB-HG0ZH4
然后我开始尝试使用“Aux”路由,但我的代码抛出了大量错误。
我在 mgechev's Angular Seed 上使用 Alpha 44
在我的 app.ts 组件中,它是非常标准的,对于 RouteConfig
我有:
@RouteConfig([
{ path: '/', component: HomeCmp, as: 'Home' },
{ path: '/run', component: RunCmp, as: 'Run' },
{ path: '/manage', component: ManageCmp, as: 'Manage' },
{ path: '/user', component: UserCmp, as: 'User' },
{ path: '/settings', component: LocalSettingsCmp, as: 'Settings' },
{ aux: '/login', component: LoginCmp, as: 'Login' }
])
我的 app.html:
<div id="main-content" class="full">
<router-outlet></router-outlet>
<router-outlet name="login"></router-outlet>
</div>
在 HomeCmp 中,我放置了一个“登录”链接:
<p>Router Link to activate login form: <a [router-link]="['/',['Login']]">Login</a></p>
现在我在该组件中有其他路由器链接可以正常工作,但是当我添加此链接时出现此错误:
异常(exception):
EXCEPTION: "/" is only allowed at the beginning of a link DSL. in [null]
BrowserDomAdapter.logError @ angular2.dev.js?v=0.0.0:21835
BrowserDomAdapter.logGroup @ angular2.dev.js?v=0.0.0:21846
ExceptionHandler.call @ angular2.dev.js?v=0.0.0:4431
(anonymous function) @ angular2.dev.js?v=0.0.0:19543
NgZone._onError @ angular2.dev.js?v=0.0.0:10711
errorHandling.onError @ angular2.dev.js?v=0.0.0:10630
run @ angular2.dev.js?v=0.0.0:141
(anonymous function) @ angular2.dev.js?v=0.0.0:10651
zoneBoundFn @ angular2.dev.js?v=0.0.0:111
lib$es6$promise$asap$$flush @ angular2.dev.js?v=0.0.0:1301
angular2.dev.js?v=0.0.0:21835
错误:
Error: "/" is only allowed at the beginning of a link DSL.
at new BaseException (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:16034:21)
at RouteRegistry.generate (http://localhost:5555/lib/router.dev.js?v=0.0.0:1645:17)
at ChildRouter.Router.generate (http://localhost:5555/lib/router.dev.js?v=0.0.0:2044:43)
at RouterLink.Object.defineProperty.set [as routeParams] (http://localhost:5555/lib/router.dev.js?v=0.0.0:1323:52)
at AbstractChangeDetector.ChangeDetector_HomeCmp_0.detectChangesInRecordsInternal (eval at <anonymous> (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20415:14), <anonymous>:118:40)
at AbstractChangeDetector.detectChangesInRecords (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20209:14)
at AbstractChangeDetector.runDetectChanges (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20192:12)
at AbstractChangeDetector._detectChangesInShadowDomChildren (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20259:14)
at AbstractChangeDetector.runDetectChanges (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20196:12)
at AbstractChangeDetector._detectChangesInLightDomChildren (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20253:14)
上下文:
{element: a, componentElement: home, context: HomeCmp, locals: Object, injector: Injector…}
它还会抛出这个:
TypeError: Cannot read property 'child' of undefined
at ChildRouter.Router.isRouteActive (http://localhost:5555/lib/router.dev.js?v=0.0.0:1803:77)
at RouterLink.Object.defineProperty.get [as isRouteActive] (http://localhost:5555/lib/router.dev.js?v=0.0.0:1315:29)
at AbstractChangeDetector.ChangeDetector_HomeCmp_0.detectChangesInRecordsInternal (eval at <anonymous> (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20415:14), <anonymous>:153:44)
at AbstractChangeDetector.detectChangesInRecords (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20209:14)
at AbstractChangeDetector.runDetectChanges (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20192:12)
at AbstractChangeDetector._detectChangesInShadowDomChildren (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20259:14)
at AbstractChangeDetector.runDetectChanges (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20196:12)
at AbstractChangeDetector._detectChangesInLightDomChildren (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20253:14)
at AbstractChangeDetector.runDetectChanges (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20193:12)
at AbstractChangeDetector._detectChangesInShadowDomChildren (http://localhost:5555/lib/angular2.dev.js?v=0.0.0:20259:14)
但它是在第一个错误之后出现的,所以我不确定它是由第一个错误还是其他原因引起的。
我也尝试了 Way from the Angular2 API Docs但它会引发相同的错误。
注意:我尝试让路由器与 Plunker 一起工作,但它不喜欢 URL 或其他东西,否则我会提供一个实际案例
2015 年 10 月 29 日更新第一个错误是路由器链接不允许您以任何方式使用“\”或“.\”。您必须指定路由名称。
Aux 仍然不工作...
最佳答案
routerLink匹配数组中第一个参数的路径
在您的情况下,它将匹配 /
或 Home
<a [routerLink]="['/',['Login']]">Login</a>
改用这个:
<a [routerLink]="['/Login']">Login</a>
据我所知,该参数是一个数组,因为路由还可以包含一个或多个通配符匹配项。
注意:Login
在链接中使用指向路由的别名(即 as
字段)。
来源:
更新:
密切关注。 angular2 团队正计划更改 RouterLink
/<router-link>
至 RouterViewport
/<router-viewport>
在未来的版本中。
更新2:
关于javascript - Angular2 路由器讨厌我的 AUX 路由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33395702/
使用 ui-router-ng2 有哪些优点和缺点?而不是新的 Angular2 路由器?过去我使用 ui-router 和 Angular 1.x 而不是使用 ngRoute,因为我需要更好地支持嵌
本文主要记录个人对小米 WR30U 路由器的解锁和刷机过程,整体步骤与 一般安装流程 类似,但是由于 WR30U 的解锁 ssh 和刷机的过程中有一些细节需要注意,因此记录一下 解锁
我有路由器 { path: 'reset-password', component: ResetPasswordComponent, } 我希望能够将其作为直接链接 (/reset-passw
所以,我试图制作一个具有 Backbone 的示例应用程序,但我无法使路由器工作,对此有什么想法吗?谢谢。这是我的路由器 var Workspace = Backbone.Router.extend(
我正在研究分布式应用程序。网络基于ZMQ(jeromq),这是我的架构: N Clients (Dealer socket) (Router) Proxy (Dealer) 1 (Dealer)
In this plunk我有一个 ui-router $state.goto这仅在第一次有效,即使我增加了 seq变量以强制重新加载。看到时间戳没有改变。这段代码有什么问题? HTML G
我有面包屑组件,测试如下。测试应覆盖75%以上。测试失败,因为 ActivatedRoute.root.children 未定义。谁知道我该如何定义它?我需要至少一个 children 作为 root
我正在使用 RC5 和 "@angular/router": "3.0.0-rc.1" 我似乎无法捕捉到旧路线(示例): /category/subcategory/subcategory/artic
我确实有一个延迟加载模块,当我转到 /lazy 时默认加载 LazyLoadedComponent。到目前为止,没问题。 此组件包含 2 个路由器 socket : 模块有以下路由: const
我试图用不同的参数路由到当前页面,但没有成功。我有一个触发的组合框: this.router.navigate(['page', selectedId]); Url 正在更改,仅此而已。 如何使用不同
我正在尝试使用 React 路由器构建 SPA。当我使用链接导航时,它工作得很好,但是刷新或写入 url 时,它给我 cannot GET/(any route except main)。我试图将 h
我无法在我的 app.js 文件中添加样式。 div 在路线内不起作用。有没有其他方法可以在路由中添加样式? : } /> } /> }> } />
根据用户角色在 react-router 中有条件地呈现路由的最佳方法是什么。我有一个案例,并非所有角色都有权查看某些路线。而且我还需要处理子路线。因此,如果主要路线之一类似于/posts,我只希望
我想使用 Flash 的 RTMFP 对等协议(protocol),但我想知道它是否值得为主流受众开发?据我了解,它使用 UDP,除非用户的防火墙/路由器配置正确,否则它变得毫无用处。 这个问题有解决
我有一 strip 有 waitOn 的路线返回 Meteor.subscribe 的钩子(Hook).每次触发路线时,我都会从我的 loadingTemplate 中看到微调器在看到实际数据之前简要
所以我最近开始尝试使用 createMemoryHistory,因为我正在构建一个将在 iframe 中呈现的应用程序。幸运的是,单击 UI 按钮,我可以在不修改 url 的情况下四处导航。但是,当我
我在我的 React redux 应用程序中使用 connected-react-router。我需要服务器端渲染和客户端渲染(我通过 limenius react bundle 在 symfony
我是一名 ios 开发人员,并试图找出 viper 架构中的路由器和 coordinator 之间的区别。 我真的找不到明确的答案是协调器只是被认为是一种模式,所以路由器毕竟只是某种协调器还是它们有不
我想要这样的东西: if ($state.get("^")) $state.go("^"); else $location.path('/'); 但它显然不起作用(即使没有父状态,它也总是与 $sta
当我从 react-router-dom 使用 BrowserRouter 时,我的路由正在工作。但是为了使用自定义历史记录,我用来自 react-router 的 Router 替换了 Browse
我是一名优秀的程序员,十分优秀!