[英]UI-Router. How can I navigate to a page in my project that I don't want to include as a State?
我仍在學習Angular和UI-Router ...因為UI-Router路線我幾乎都走了,因為每個人都告訴我這是路要走。
我最初將登錄頁面作為所有州的一部分..但決定最好將其保留為單獨的獨立頁面
但是我不知道如何重定向到登錄頁面...
app.config(['$urlRouterProvider', '$stateProvider', function ($urlRouterProvider, $stateProvider) {
$urlRouterProvider
.otherwise('');
//what i used to have, will remove this
$stateProvider
.state('login', {
url: '/login',
templateUrl: 'Account/Login',
})..etc
所以現在如果我想現在重定向到實際的URL ..我該怎么做呢?
我試過了:
$location.url('/Account/Login');
$location.path('/Account/Login');
但它們似乎只是附加到URL。 如何使用UI-Router並轉到項目的非狀態頁面?
您始終可以訪問任何本機javascript窗口方法。 Angular以$window
提供了可注入的引用
$window.location = '/non-angular-url';
// OR
window.location = '/non-angular-url';
$ window:對瀏覽器窗口對象的引用。 雖然window在JavaScript中全局可用,但由於它是全局變量,因此會引起可測試性問題。 在角度上,我們總是通過$ window服務引用它,因此它可能會被覆蓋,刪除或嘲笑以進行測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.