问题标签 [angular-route-segment]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
2312 浏览

javascript - Angular2 - LoggedInGuard 没有提供者

我正在制作一个 Anuglar2 rc-4 Web 应用程序。我正在尝试限制路由,但是当我添加登录保护时,它告诉我没有提供程序。我的正常登录服务代码工作正常,就在我尝试添加登录保护和 canActive 路由时。有关如何解决此错误的任何想法?

路线.ts

引导.ts

登录的.guard.ts

0 投票
1 回答
722 浏览

angularjs - 使用 angularjs 路由运行 document.ready

我正在尝试使用 angularjs 中的路由从 Materialize 框架运行函数 .parallax() 。我已经为每个模板配置了命令 document.ready 但这不起作用。这只是第一次。使 document.ready 调用 $('.test').test(); 这样的函数的最佳方法是什么?使用路线?我将等待!谢谢!

我的路线的模板 HTML:

控制器:

谢谢!

0 投票
1 回答
115 浏览

javascript - 角度嵌套路线未正确加载

问题 #1

我正在尝试为自己定制 angular-route-provider 示例。我正在尝试为第 1 节中的每个元素实现单独分隔的选项卡。

我的部分 #/section1/hs(hs.html) 仍然为选项卡实现 #/section1/hs/X 而不是 #/section1/hs/ov 。

您可以在此处查看 app.js 代码。

我尝试过使用首选项示例和其他方法,但它不起作用。

问题 #2

此外,当我在 templateUrl 中使用另一个角度应用程序路径时,页面似乎无法正确加载(仅显示文本)。是不是因为不能在 templateUrl 中调用另一个 Angular 应用程序。我不确定这一点,因为我不是 AngularJS 专家。

下面是我的这个例子的代码。任何帮助将不胜感激。

section1.html

hs.html

0 投票
1 回答
695 浏览

angularjs - AngularJs - Route by exact match only is possible?

In my app, I would like to match the url exactly. in case the url doesn't match exactly, I require to redirect to defualt as '`.

at present I require to test:

localhost:3000/sn=1234 or localhost:3000/sn=abc123 or localhost:3000/sn=abc123

that means, minimum the sn= should presence with values whether by number or alphabets or both mixed.

at present my state looks like this:

But it works for : both localhost:3000/sn=, localhost:300/sn - how to prevent this? and match the required value?

Thanks in advance.

0 投票
1 回答
632 浏览

angular - Angular2子路线

我在 angular2 中有根模块和一个子模块,它们都定义了自己的路由。在子模块中,我将 RouterModule 配置为

在 root module(parent) 中,将 RouterModule 配置为

我在子节点和根节点中使用相同的路由名称

在儿童

在根(父)中

我在根模块中导入子模块

当我加载我的组件(我的意思是根模块)时,默认路由总是去子模块而不是根模块,即它打印“我是孩子”,正如我所期望的“我是父母”,只有当我加载子路由时加载它,如何将它路由到根(父)模块而不是子模块的默认路由?

0 投票
4 回答
11380 浏览

angularjs - 在angularjs中成功登录后如何重定向到其他页面?

您好我正在开发一个以 angularjs 作为前端和 web api2 作为后端的应用程序。我对 Angular 和 web api 都很陌生。我已经在 angularjs 中完成了登录页面。登录成功后,我想转到位于 Views/Home/index.cshtml 的名为 Index.cshtml 的页面。我正在尝试如下。

这是我的控制器代码。

这是我的 module.js

服务.js

我正在尝试使用 window.location 但它不起作用。我可以在这里得到一些帮助吗?任何帮助,将不胜感激。谢谢你。

0 投票
0 回答
128 浏览

angularjs - Angular 1.6 NestedRoute(单页应用)

我正在尝试使用 ngRoute 在 agularjs 1.6 中创建单页应用程序。我的代码如下。

角码

HTML

我的代码在路由中运行良好。在用户数据中,我有子菜单的地址,资格。我不知道我应该如何为它编写角度路由代码(嵌套路由)。下面是我的 html 代码。

HTML

0 投票
1 回答
1122 浏览

angularjs - 角度路由和引导导航栏

我在让引导导航栏 + 角度路由工作时遇到问题。我不明白发生了什么,因为另一个应用程序上的一个非常相似的代码正在运行。

我的 index.html 中有以下 html

我的 app.js:

当我点击统计链接时,我的 URL 显示: http://localhost/myApplication/#!/#statistic 并且我看到了主页模板。

然后主页按钮显示“ http://localhost/myApplication/#!/

是个 #!这是什么原因?

0 投票
1 回答
58 浏览

angularjs - 我不能将第三方 js 与 angular js 和 ASP.NET MVC 一起使用

您好,我正在使用 ASP.NET MVC 和 Angular js 创建应用程序。

一切都运行良好,但是当我想将任何第三方 js 用于 angular js 时,它不允许这样做......

我创建了三个 js 文件。

1)应用程序.js

2)控制器.js

3)服务.js

4)在视图中实现

我想使用多选js来实现多选下拉列表。

我只在控制器中完成了以下一行更改并查看了进一步的更改。

应用程序.js

它也运行良好,但也使用此 app.js 的其他页面给了我一个错误。

在此处输入图像描述

0 投票
1 回答
1900 浏览

angular - Angular2:只需更新路线的最后一段

我的应用程序中有一条路线,格式为localhost/opportunity/:id/volunteers. 我想构建一个routerLink导航到同一级别的不同页面(即localhost/opportunity/:id/waitlist)。按照API 文档Routerlink中概述的选项,我得到的印象是routerLink表单中的arouterLink="./volunteers" 应该链接到我当前所在的同一页面。因此,routerLinkActiveforrouterLink="./volunteers"应该表示链接是活动的。但它并没有这样做......

相关路线如下所示:

routerLink="./volunteers"似乎导航到localhost/volunteers不存在的。我也尝试过 , , 等形式的链接routerLink="../../volunteers"routerLink="../volunteers"它们routerLink="././volunteers"也不起作用,不是我认为它们会起作用)。

关于我做错了什么有什么建议吗?显然,我可以:id手动从链接中提取 ' 并将其插入(类似于routerLink="['opportunity', extractedId, 'volunteers']"),但这感觉是错误的方式,我不想:id在我的应用程序中手动提取 '。似乎我只是做错了什么。我已经搜索了一段时间,但还没有找到这个问题的答案。

小编辑:我还要说这个模块直接加载到根模块中。

更新:

当我尝试 arouterLink="../"时,它显示为该localhost/opportunity/:id/volunteersurl 处于活动状态,但单击该链接会将我带回主页(即localhost/)。我非常确信我的路由器只认为我的应用程序中有一个子级别(即localhost/opportunity/:id/volunteers并且localhost/calendar似乎都是 的直接子级localhost。而localhost/opportunity/:id/volunteers应该是 的直接子级localhost/opportunity/:id。我需要通过router'forChild()方法加载路由吗?将其视为子级?换router一种说法,是否有可能因为该模块的所有路由都加载在同一个forChild()块中,所以它们被视为同一级别的子级?