負載AppComponent要問我的問題,我會爲例如使用官方angular.io英雄教程。Angular2 - 在「/」沒有任何其他成分(英雄教程)
(這是點6.Routing - Tutorial的結果)。
當你在控制檯上npm start
,AppComponent的HTML被加載,但/dashboard
也默認加載(當URL是http://localhost:3000
它被自動重定向到http://localhost:3000/dashboard
)。
我的問題是:當你引入http://localhost:3000
,是否可能只加載HTML AppComponent並且不自動重定向到dashboard
?
我試圖從刪除app.routing.ts
{
path: '',
redirectTo: '/dashboard',
pathMatch: 'full'
},
但後來我得到5這樣的錯誤EXCEPTION: Error: Uncaught (in promise): Error: Cannot match any routes: ''
。
正式運動員是:https://angular.io/resources/live-examples/toh-5/ts/plnkr.html。
謝謝!
對不起,我從angular2開始。我不明白爲什麼放置路徑:''和加載組件:DashboardComponent。我想要的不是加載儀表板,但我知道你的代碼加載它。 –
添加與您的路由器相關的代碼,以便我們可以看到更多的應用程序,以便正確解釋您;)這是很好的dw。 –
我的代碼與你在問題中提到的重擊者所發現的完全一樣。 –