我正在使用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 –