2017-04-12 60 views
0

角JS 2路由正在發生的事情,但沒有在URL變化角JS 2路由正在發生的事情,但在URL沒有改變

海所有,

是新來的角JS 2,我已經創造了三層路由實例標籤它們在角JS 2不同類型的形式.. 1.Template從動 2.模型驅動 3.模型驅動用表單生成

enter image description here

問題是,當我點擊另一個標籤文件內容的變化,但網址,驗證工作不

我已經上傳在github上 很高興全部內容,如果有人幫我清理代碼也。 上午上午還提前 這裏尋找貢獻者爲表單模板

由於是代碼爲app.component.ts

<nav> 
      <a routerLink="/angulartemplateform" routerLinkActive="active">Angular Forms Using Template</a> 
      <a routerLink="/angularmoduleformdata" routerLinkActive="active">Angular Forms Using Model</a> 
      <a routerLink="/angularmodulebuilder" routerLinkActive="active">Angular Forms Using Form Builder</a> 
      </nav>    
      <router-outlet></router-outlet> 

Github的地址:: https://github.com/selva1990kumar/AngularJS-Forms

回答

1

這是因爲路由你還沒有設置任何空路由路徑

const routes: Routes = [ 
    ////////////////////////////////////////////////////////////////////// 
     { path: '', redirectTo: 'angulartemplateform', pathMatch: 'full' }, 
    /////////////////////////////////////////////////////////////////////// 
     { path: 'angulartemplateform', component: EmployeeListComponent}, 
     { path: 'angularmoduleformdata', component: EmployeeDetailComponent}, 
     { path: 'angularmodulebuilder', component: EmployeeFormComponent}, 


    ] 
+0

{path:'',redirectTo:'angulartemplateform',pathMatch:'full '},我已經嘗試了上面的代碼,但它不工作還問題是它去了angularmoduleformdata,angularmodulebuilder鏈接並返回到angulartemplateform – selva

+0

好吧你得到的錯誤 – Aravind

+0

angulartemplateform:1拒絕執行從'http: //localhost:3000/app/app-routing.module.ts',因爲它的MIME類型('video/mp2t')不可執行。 popup.js:121 Uncaught ReferenceError:XML未定義 在popup.js:121 (匿名)@ popup.js:121 core.umd.js:210 Angular 2正在開發模式下運行。調用enableProdMode()以啓用生產模式。這是我得到的錯誤,當我加載項目 – selva