RC5中Angular2 ng2材料的使用

时间:2016-09-06 04:36:34

标签: angular

我正在使用以下方法在我的文件夹中安装ng2-material:

npm install --save ng2-material @angular2-material/core

然后我把这个链接放在我的index.html

<link rel="stylesheet" href="node_modules/ng2-material/ng2-material.css">
<link rel="stylesheet" href="node_modules/ng2-material/font/font.css">

我把ng2-material也放在我的systemjs.config.js

 var map = {
    'app':                        'app', // 'dist',

    '@angular':                   'node_modules/@angular',
    'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
    'rxjs':                       'node_modules/rxjs',
    'moment':                     'node_modules/moment/moment.js',
    'ng2-material':               'node_modules/ng2-material'
  };

var packages = {
    'app':                        { main: 'main.js',  defaultExtension: 'js' },
    'rxjs':                       { defaultExtension: 'js' },
    'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
    'moment'                     :{format: 'cjs'},
    'ng2-material':               {defaultExtension: 'js'}
  };

这是我感到困惑的部分。

在我的模块中,我称之为:

import {MATERIAL_PROVIDERS, MATERIAL_DIRECTIVES} from "ng2-material";
@NgModule({
  imports: [
BrowserModule,
    FormsModule
],
declarations: [
    MATERIAL_DIRECTIVES    <<<<<<<----------
],
providers: [
MATERIAL_PROVIDERS           <<<<<<<<<<<<<<<-------------
]
  bootstrap: [ AppComponent ],
  schemas: [ CUSTOM_ELEMENTS_SCHEMA ]
})
export class AppModule {
}

当我编译时,我总是得到这样的错误:

zone.js:101 GET http://localhost:3000/node_modules/ng2-material/ 404 (Not Found)scheduleTask @ zone.js:101ZoneDelegate.scheduleTask @ zone.js:345Zone.scheduleMacroTask @ zone.js:282(anonymous function) @ zone.js:122send @ VM22510:3fetchTextFromURL @ system.src.js:1156(anonymous function) @ system.src.js:1739ZoneAwarePromise @ zone.js:602(anonymous function) @ system.src.js:1738(anonymous function) @ system.src.js:2764(anonymous function) @ system.src.js:3338(anonymous function) @ system.src.js:3605(anonymous function) @ system.src.js:3990(anonymous function) @ system.src.js:4453(anonymous function) @ system.src.js:4705(anonymous function) @ system.src.js:408ZoneDelegate.invoke @ zone.js:332Zone.run @ zone.js:225(anonymous function) @ zone.js:586ZoneDelegate.invokeTask @ zone.js:365Zone.runTask @ zone.js:265drainMicroTaskQueue @ zone.js:491ZoneTask.invoke @ zone.js:435
login:55 Error: Error: XHR error (404 Not Found) loading http://localhost:3000/node_modules/ng2-material
        at XMLHttpRequest.wrapFn [as _onreadystatechange] (http://localhost:3000/node_modules/zone.js/dist/zone.js:789:30)
        at ZoneDelegate.invokeTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:365:38)
        at Zone.runTask (http://localhost:3000/node_modules/zone.js/dist/zone.js:265:48)
        at XMLHttpRequest.ZoneTask.invoke (http://localhost:3000/node_modules/zone.js/dist/zone.js:432:34)
    Error loading http://localhost:3000/node_modules/ng2-material as "ng2-material" from http://localhost:3000/app/app.module.js

0 个答案:

没有答案