2016-10-13 10 views
0

cshtmlファイルにangular2モジュールをロードしようとしています。 私はcshtmlファイルに必要なすべてのスクリプトをコピーしようとしましたが、/ app/mainのロードに失敗すると正しく読み込まれませんでしたので、htmlファイルで作業しています。cshtmlファイルにangular2をロード

これはオリジナルのhtmlファイルタグです。

<!DOCTYPE html> 
<html> 

<head> 
    <meta name="viewport" content="width=device-width" /> 
    <title></title> 
    <script src="/node_modules/es6-shim/es6-shim.js"></script> 
    <script src="/node_modules/angular2/bundles/angular2-polyfills.js"></script> 
    <script src="/node_modules/systemjs/dist/system.src.js"></script> 
    <script src="/node_modules/rxjs/bundles/Rx.js"></script> 
    <script src="/node_modules/angular2/bundles/angular2.dev.js"></script> 
    <script> 

    System.config({ 
     packages: { 
      'app': { 
       defaultExtension: 'js' 
      } 
     }, 
    }); 
    System.import('/app/main').then(null, console.error.bind(console)); 
    </script> 
</head> 

<body> 
    <div> </div> 
</body> 

</html> 
<pm-app> 
    <div> 
     <p> Please wait ...</p> 
    </div> 
</pm-app> 

そして、それは次のエラーを思い付く:私は次のコードでCSHTMLでこれを試してみた

Failed to load resource: the server responded with a status of 404 (Not Found)

@{ 
    ViewBag.Title = "Index"; 
} 
<script src="~/node_modules/es6-shim/es6-shim.js"></script> 
<script src="~/node_modules/angular2/bundles/angular2-polyfills.js"></script> 
<script src="~/node_modules/systemjs/dist/system.src.js"></script> 
<script src="~/node_modules/rxjs/bundles/Rx.js"></script> 
<script src="~/node_modules/angular2/bundles/angular2.dev.js"></script> 
<script> 

    System.config({ 
     packages: { 
      'app': { 
       defaultExtension: 'js' 
      } 
     }, 
    }); 
    System.import('/app/main').then(null, console.error.bind(console)); 
</script> 


<h2>Index </h2> 

<pm-app>Loading App ...</pm-app> 

これも同じエラーメッセージが表示されます。私も試しました 1.すべてのスクリプトをレイアウトページのヘッダーセクションに入れます。 2.レンダリングセクションをレイアウトページに置き、index.cshtmlファイルにセクションを追加します。

3回とも同じエラーメッセージが表示されたので、この方法(cshtmlで角度モジュールを読み込む)を行うのはまったく悪い習慣であるのか、それに何らかの修正があるのだろうかと思いました。

ご協力ありがとうございます。

乾杯。

+0

を_layout.cshtmlためにあなたのライブラリをコピーしてください。バインド(コンソール)); –

+0

こんにちはPawel、あなたの入力をありがとう。私はindex.htmlがルートパスにあるので、パス自体が正しいと思います。 .jsを追加すると、 '/app/main.js'が呼び出されると、app.componentである次のjsファイルが検索されます。だから、それはjs拡張設定を認識していないように見えます。 – rlee923

+0

」というタグがありません。後で角度2を使用すると、System.configのメインオプションが未定義のまま残っているかどうかわかりません。 'パッケージ:{'app':{main: '/ app/main'、defaultExtension: 'js'}}'と 'System.import( 'app')'を試してください。マップはシステムローダーのパスヒントを提供します。 – silentsod

答えて

0

は、あなただけのこのhttps://www.youtube.com/watch?v=WA4dPYlRwrE&spfreload=5 は、私はあなたがSystem.import `に誤ったパス( '/アプリ/メイン')。そして、(ヌル、console.errorを持って推測している

+0

Phusanakiatを入力していただきありがとうございます。私は素早く見て、それが.netのコアであることに気づいた。私は詳細を見て、私がどうやって行くのかを教えてくれるでしょう。 – rlee923

関連する問題