2016-05-17 45 views
0

我不知道如何命名的問題,但這裏是我的情況鏈接重定向到NG-視圖中的頁面

我的模板是這樣的:

├──指數html的
├──...
├──佔
│├──的index.html
│├──授權
││├──的login.html
││├─ signup.html
││└──儀表盤

所以第一索引頁是頭版,第二索引頁包含NG-視圖,其是用於登錄頁面,註冊頁,和儀表板頁面的模板。

我已經做:

app.config(['$routeProvider', function($routeProvider) { 
    $routeProvider. 
     when('/login', { 
      title: 'Login', 
      templateUrl: 'authorization/login.html', 
      controller: 'authCtrl' 
     }) 
     .when('/signup', { 
      title: 'Signup', 
      templateUrl: 'authorization/signup.html', 
      controller: 'authCtrl' 
     }) 
     .when('/dashboard', { 
      title: 'dashboard', 
      templateUrl: 'authorization/dashboard/index.html', 
      controller: 'authCtrl' 
     }) 
     .otherwise({ 
      redirectTo: "/login" 
     }); 
    } 
]) 
.run(['$rootScope', '$location', 'apiService', function ($rootScope, $location, apiService) {... 
}]); 

不過,我想補充的第一個索引頁面上兩個環節,一個重定向到登錄頁面,另一個到註冊頁面。因爲login.html和signup.html都在ng-view內,所以我不能使用<a href="account"></a>,因爲它只會進入登錄頁面。

我曾嘗試:

<div class="nav_item_extra"><a class="loggedIn" href="account/authorization/login">Sign in</a></div> 
<div class="nav_item_extra"><a class="loggedIn" href="account/authorization/signup.html">Register</a></div> 

兩人都不工作。

有人可以幫助我如何使鏈接?謝謝

+0

應使用符合國家的名字,而不是HREF UI-SREF屬性。例如:你的第二個鏈接只是試圖模板路徑而不是實際狀態 –

+0

@NimaMarashi反正沒有使用ui-router?我沒有在這個網站上使用。 –

回答

0

你只錯過 '#'(在您的href哈希標籤)

<div class="nav_item_extra"><a class="loggedIn" href="#/login">Sign in</a> 
</div> 
<div class="nav_item_extra"><a class="loggedIn" href="#/signup">Register</a> 
</div> 
+0

哦,謝謝你......我不知道爲什麼我沒有嘗試它......我認爲「#」是不允許做鏈接路徑的東西.... –

+0

即時通訊很高興它幫助:)有人解釋有關'#'標記在這裏http://stackoverflow.com/questions/14319967/angularjs-routing-without-the-hash?answertab=active#tab-top – mtamma

0

這要高度重視工作:

<div class="nav_item_extra"><a class="loggedIn" href="login">Sign in</a></div> 
<div class="nav_item_extra"><a class="loggedIn" href="signup">Register</a></div> 
+0

它沒有,它顯示404,因爲它找不到/登錄。而login.html和signup.html實際上存儲在public_html/partner/account/authorization中。通過使用「/登錄」,它會去我的根文件夾。 –

+0

是否有任何理由在每條路線之前都有'/'?爲什麼不'登錄'而不是'/登錄'?更新我的回答 –

相關問題