问题标签 [angular-routing]
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.
angularjs - 单击按钮时如何同时插入两个不同的模板?
我知道如何在 url 更改(使用$routeProvider
)和带有ng-view
. 但是,我还想同时将另一个模板插入到不同的元素中。我该怎么做呢?例如,我想在将模板插入到replace-this
元素中的同时$routeProvider
将模板插入到ng-view
.
提前感谢您提供的任何帮助!
angularjs - 当 url 中有参数时,如何设置 $routeProvider 来重定向页面?
我的页面上有一个链接,其中包含一个 id 参数 (123),如下所示:
我无法使$routeProvider
以下工作:
我错过了什么?我有类似的代码可以工作,但是当我没有参数时。我做错的参数是什么?
angularjs - AngularJs - 在 $locationChangeStart 中确定下一个位置的路线
最近,我在尝试确定如果会话无效时我应该将用户重定向到登录页面时,我发现了 AngularJS 中未记录的 $locationChangeStart 事件。
我正在使用以下方法监听事件:
wherenextLocation
和previousLocation
是应用程序内位置的绝对 URL。
我的问题是:AngularJS 是否公开了将 url 与路由匹配的能力,就像它的内部路由引擎查看绝对 URL 是否与定义的路由匹配一样?
如果不是,那么基于绝对 URL 检测路由的最佳方法是什么?
angularjs - Angular UI-Router 测试范围继承
我正在尝试为嵌套状态编写单元测试。该状态从父状态继承了一些范围元素。在我的测试中,我正在创建控制器,它显然不可见父状态,因此不可见继承的范围项。
AccountCtrl 定义了所有子状态所需的许多元素。
AccountViewCtrl 定义其他元素,但从父 AccountCtrl 继承元素
测试失败,因为我只是在实例化控制器并且没有父状态和相关元素的可见性。是否有测试 ui-router 状态的最佳实践方法?
angularjs - AngularJS路由在PhoneGap中无法正常工作
我一直在拼命想弄清楚为什么 angularJS 路由对我来说在 phonegap 中不起作用。我正确设置了所有文件,并且没有收到任何错误。我正在尝试使用 $location.url 服务直接从角度更改 url。因此,当您点击 div 时,控制器将具有 $location.url("profile") 例如,并且不会发生任何事情。我尝试了在这个stackoverflow中找到的解决方案,但这对我不起作用。我做错了什么,还是有更好的方法来解决这个问题?以下是我设置的路由
示例控制器将是:
一如既往,非常感谢任何帮助。
angularjs - angularjs路径更改不起作用
我的 index.html 文件中有一个导航栏区域,其余内容位于 ng-view 中。在导航栏中,它显示用户的用户名并有一个注销链接。单击该链接注销用户,我想将他们重定向回登录页面。
这是我的导航栏控制器中的注销方法:
我的路由器如下:
这是我的 index.html 文件的主体部分:
知道为什么它没有改变吗?
angularjs - Angular 正在打印路线,而不是在视图中呈现部分
我的应用程序设置$routeProvider
为:
我index.html
的是:
当我打开索引页面时,我会看到超链接,但是当我单击它时,会显示文件路径,而不是在<div ng-view></div>
.
javascript - AngularJS - automatically adding hash tag to URLs - overwriting search params
I"m running into an issue when I click on a quicknav, the anchor tag replaces my search parameters in the URL.
'example.com/search?hash=1234'
becomes 'example.com/search#FAQ'
instead of 'example.com/search?hash=1234#FAQ'
How do I fix this? Version 1.1.5
HTML anchor tags:
#xA;I do have HTML5 mode enabled if that makes a difference:
#xA;angularjs - Angular.js - 通过 $route 或 $routeParams 访问参数
我有一个控制器,我在其中注入 $route 和 $routeParams 但是当我去通过
$route.routes.current.params.test ->> 当前未定义 $routeParams.test ->> 测试未定义
当我使用 console.log($route) 或 console.log($routeParams) 时,这两个对象似乎都被正确填充
我很困惑。console.log 的值怎么会在我执行 console.log 的同一控制器中失败?
更新:示例代码
angularjs - 存在哈希符号时的AngularJS routeProvider
我有一个托管在 IIS 上的应用程序。应用程序网址是
http://localhost/tool
当我通过输入此 url 加载页面时,url 路径更改为
http://localhost/tool#/tool
$routeProvider
我在配置中没有任何内容。我想处理一个 URL 请求,例如,
http://localhost/tool#/request/:param1/:param2
或者如果可能的话
http://localhost/tool#/request?param1=Value&?param2=value
如何编写$routeProvider
配置?
在我的情况下,用户需要一个直接 URL 来获取页面的状态,因此用户可能不会http://localhost/tool
以http://localhost/tool#/request/:param1/:param2
.
请帮忙。