我正在使用Angular2 beta與angular2-material alpha.3它們是兼容的,但我遇到了映射問題。Angular2材料映射問題
在我的公開/ index.html的我有這個系統安裝在我的組成部分之一,當我嘗試導入並將其添加到指令中要使用的模板,如下圖所示
System.config (
{
packages: {
app: {
format : 'register',
defaultExtension: 'js'
}
},
map: {
'@angular2-material/input': 'node_modules/@angular2-material/input'
}
}
);
System.import ('app/boot').then (null, console.error.bind (console));
但:
import { Component } from 'angular2/core';
import { ControlGroup, Validators, FormBuilder } from 'angular2/common';
import { Http, Headers } from 'angular2/http';
import { ConfigService } from '../../services';
import {MD_INPUT_DIRECTIVES} from '@angular2-material/input';
@Component({
selector: 'test-form',
providers: [],
templateUrl: ConfigService.APP_FOLDER + '/components/test/test.html',
directives: [MD_INPUT_DIRECTIVES]
})
我得到這個錯誤:
angular2-polyfills.js:127 GET http://localhost:8080/node_modules/@angular2-material/input 404 (Not Found)scheduleTask @ angular2-polyfills.js:127ZoneDelegate.scheduleTask @ angular2-polyfills.js:362Zone.scheduleMacroTask @ angular2-polyfills.js:299(anonymous function) @ angular2-polyfills.js:148send @ VM1191:3fetchTextFromURL @ system.src.js:1154(anonymous function) @ system.src.js:1735ZoneAwarePromise @ angular2-polyfills.js:610(anonymous function) @ system.src.js:1734(anonymous function) @ system.src.js:2759(anonymous function) @ system.src.js:3333(anonymous function) @ system.src.js:3600(anonymous function) @ system.src.js:3985(anonymous function) @ system.src.js:4448(anonymous function) @ system.src.js:4700(anonymous function) @ system.src.js:406ZoneDelegate.invoke @ angular2-polyfills.js:349Zone.run @ angular2-polyfills.js:242(anonymous function) @ angular2-polyfills.js:597ZoneDelegate.invokeTask @ angular2-polyfills.js:382Zone.runTask @ angular2-polyfills.js:282drainMicroTaskQueue @ angular2-polyfills.js:500ZoneTask.invoke @ angular2-polyfills.js:452 angular2-polyfills.js:349 Error: Error: XHR error (404 Not Found) loading http://localhost:8080/node_modules/@angular2-material/input
你只在這裏配置systemjs嗎?如果是的話,你甚至沒有設置angularclient,讀取角度快速啓動或克隆它的存儲庫,並看看包含的系統配置文件 –
@mahdimahzuni我的導師給了我一個樣板他設置,因爲我必須創建一個Web應用程序MEAN堆棧,我無法找到一個angular2 beta systemjs.config.js文件,所以手動做,但是,我只做到了,我無法從測試版遷移到rc –
做到這一點,然後檢查您是否有system.config.js文件,並在您的主html文件(如index.html)中引用它,並查看它的內容是否與此頁面中提供的內容類似https://angular.io/docs/ts/latest/quickstart .html#!##create-and-configure –