2016-10-12 6 views
1

最初のAngular 2アプリケーションで作業を開始しましたが、いくつかの問題が発生しています。リソースのロードに失敗しました(404エラー)(Material Design Lite)

私のIDEは、私はマテリアルデザインライトを使用しようとすると私の問題が発生する角度CLI

でプロジェクトを生成しWebStorm &です。私は私のindex.htmlで3つの依存関係をインポートした

<link rel="stylesheet" href="../../node_modules/material-design-lite/material.min.css"> 
<script src="../../node_modules/material-design-lite/material.min.js"></script> 
<link rel="stylesheet" href="../../node_modules/material-design-icons/iconfont/material-icons.css"> 

しかし、リソース・エラーを読み込むことができませんでしたでは、ブラウザで、すべての3つの結果をNGがサーブ呼び出した後。

これを解決する方法についてのご意見はありますか?

注:index.htmlには、私のプロジェクトフォルダ

答えて

0

あなたはそのように依存関係を参照してはならないのsrcフォルダにある、アプリのフォルダ内にあります。

npm i material-design-lite 

を使用してインストールしてから、angle-cli.jsonでスタイルやスクリプトに追加する必要があります。

すなわち

{ 
    "project": { 
    "version": "1.0.0-beta.16", 
    "name": "test" 
    }, 
    "apps": [ 
    { 
     "root": "src", 
     "outDir": "dist", 
     "assets": "assets", 
     "index": "index.html", 
     "main": "main.ts", 
     "test": "test.ts", 
     "tsconfig": "tsconfig.json", 
     "prefix": "app", 
     "mobile": false, 
     "styles": [ 
     "../node_modules/material-design-lite/material.min.css", 
      "../node_modules/material-design-icons/iconfont/material-icons.css" 

     ], 
     "scripts": [ 
     "../node_modules/material-design-lite/material.min.js" 
     ], 
+0

だから私はindex.htmlをからそれらを削除し、代わりにアンギュラcli.jsonに入れ。 MDLマークアップは無視され、基本的なHTML要素が表示されます。 –

+0

ディレクティブ –

+0

のngmoduleにそのコンポーネントを追加する必要があるため、webpackプロジェクトを使用すると同じエラーが発生します。 – Skynet

関連する問題