2017-06-02 20 views
0

私はASP.NET Core Webアプリケーションで、Angular 2とVS 2015をIDEとして使用しています。これはまったく新しいものなので、私はこのチュートリアルに従ってこのページの作業を続けてきました。最終的にすべてをまとめるとルーティングの問題に直面します。ページは読み込み中のタグにとどまり、ModuleViewComponentのコンテンツは表示されません。 stackoverflowの質問をたくさん読んでいますが、修正できませんでした。Angular 2ルーティングがASP.netコアMVCで動作しない

マイmain.tsファイルは次のようになります。

// main entry point 
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 
import { AppModule } from './app.module'; 

platformBrowserDynamic().bootstrapModule(AppModule); 

app.module.ts

import { NgModule } from '@angular/core'; 
import { BrowserModule } from '@angular/platform-browser'; 
import { FormsModule } from '@angular/forms'; 
import { HttpModule } from '@angular/http'; 
import { RouterModule, Routes } from '@angular/router'; 
import { NgForm } from '@angular/forms'; 
import { AppComponent } from './app.component'; 

import { ModuleViewComponent } from './components/CommonComponents/moduleView.component/moduleView.component'; 

const myRoutes: Routes = [ 
{ 
    path: 'home', 
    component: ModuleViewComponent 
}, 
{ 
    path: '/', 
    redirectTo: 'home', 
    pathMatch: 'full' 
} 
]; 

@NgModule({ 
imports: [ 
    RouterModule.forRoot(myRoutes), 
    BrowserModule, 
    FormsModule, 
    HttpModule 
], 
declarations: [ 
    AppComponent, 
    NavbarComponent, 
    ModuleViewComponent 
], 
bootstrap: [AppComponent] 
}) 

export class AppModule { } 

app.component.ts

import { Component } from '@angular/core'; 

@Component({ 
selector: 'my-app', 
template:'<router-outlet></router-outlet>' 
}) 
export class AppComponent { 
} 

そしてindex.cshtml

@{ 
ViewData["Title"] = "Home Page"; 
} 

<my-app>loading...</my-app> 

どのように私は、これはコンポーネントのコンテンツを仕事と表示するように得ることができますか?どのような助けも、歓迎よりも前にありがとうございます。

答えて

0

私はAsp.net MVCフレームワークを使って角型(Angular v4)アプリケーションを作成するための段階的な詳細を説明するサンプルアプリケーションを作成しました。以下はリンクです。これがあなたを助けることを願っています角度がリクエストを受信できるように、プロジェクトのルート設定ファイルを更新する必要があります。

http://hive.rinoy.in/angular4-and-asp-net-mvc-hybrid-application/

http://hive.rinoy.in/routing-in-angular-asp-net-mvc-application/

+0

私はそれを試してみるつもりだと私はあなたが – Mig

+0

提供されたリンクは死んでいる知ってもらおう。 – stckvflw

+0

私はリンクのURLを更新しました。再度確認してください。 – rinoy

関連する問題