[英]Angular 2 RC6 problems with SystemJS
I'm having some problems getting my app to run after updating to RC6. 我在更新到RC6后运行应用程序时遇到了一些问题。
I changed my systemjs due to the official example from changelog . 由于changelog的官方示例,我更改了我的systemjs。
But I still get compile errors like this one: "Module '"D:/Myproject/WebClient/node_modules/@angular/router/index"' has no exported member 'ROUTER_DIRECTIVES'." 但是我仍然遇到像这样的编译错误:“模块”“D:/ Myproject / WebClient / node_modules / @ angular / router / index”'没有导出的成员'ROUTER_DIRECTIVES'。“
It looks like the compiler takes the default index.js file instead the umd package... The compiling is done by gulp task with the following options: 看起来编译器采用默认的index.js文件而不是umd包...编译是通过gulp任务完成的,具有以下选项:
"module": "system", "moduleResolution": "node", "target": "ES5", "experimentalDecorators": true, "emitDecoratorMetadata": true, "allowSyntheticDefaultImports": false
I get this errors for router module and forms module. "module": "system", "moduleResolution": "node", "target": "ES5", "experimentalDecorators": true, "emitDecoratorMetadata": true, "allowSyntheticDefaultImports": false
我收到路由器模块和表单的错误模块。
Router is V3.0.0-rc.2 and forms is V.2.0.0-rc6 Router为V3.0.0-rc.2,格式为V.2.0.0-rc6
Think it is more a problem that my systemJs is not read correctly anyhow. 认为无论如何我的systemJs无法正确读取更是一个问题。
SystemJS: SystemJS:
var map = {
'app': 'public/app',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'rxjs': 'npm:rxjs',
'symbol-observable': 'npm:symbol-observable',
'moment': 'npm:moment',
'ng2-charts': 'npm:ng2-charts',
'ng2-translate/ng2-translate': 'npm:ng2-translate',
'angular2-highcharts': 'npm:angular2-highcharts',
'highcharts/highstock.src': 'npm:highcharts',
'primeng': 'npm:primeng'
};
var packages = {
'app': { main: 'main', defaultExtension: 'js' },
'rxjs': { main: 'Rx.js', defaultExtension: 'js' },
'moment': { main: 'moment', defaultExtension: 'js', type: 'cjs'},
'symbol-observable': { main: 'index.js', defaultExtension: 'js' },
'ng2-charts': { main: 'ng2-charts', defaultExtension: 'js' },
'ng2-translate/ng2-translate': { main: 'ng2-translate', defaultExtension: 'js' },
'angular2-highcharts': { main: 'index', defaultExtension: 'js' },
'highcharts/highstock.src': { main: 'highstock.src', defaultExtension: 'js' },
'primeng': { defaultExtension: 'js' }s
};
System.config({
map: map,
packages: packages,
paths: {
// paths serve as alias
'npm:': 'node_modules/'
}
//format: 'register'
});
Aynbody any idea? 艾恩有什么想法吗? Thanks in advance 提前致谢
根据ngModule
新变化,删除了不推荐的指令,并且对于默认的角度功能,在ngModule
中引入了ngModule,因此您必须根据路由文档配置@angular/router
RouterModule
来配置路由,然后您可以使用RouterModule
提供的RouterModule
。
You have to remove ROUTER_DIRECTIVES
, FORM_DIRECTIVES
and CORE_DIRECTIVES
from all your components. 您必须从所有组件中删除ROUTER_DIRECTIVES
, FORM_DIRECTIVES
和CORE_DIRECTIVES
。 Instead, create modules for all components. 而是为所有组件创建模块。 Import BrowserModule
in your AppModule
and import FormModule
for all Modules you need form directives for. 在AppModule
导入BrowserModule
并导入FormModule
以FormModule
所需的所有模块指令。
Further information can be found here: https://angular.io/docs/ts/latest/guide/architecture.html 更多信息可以在这里找到: https : //angular.io/docs/ts/latest/guide/architecture.html
An AppModule looks eg like the following: AppModule看起来如下所示:
import {NgModule} from '@angular/core';
import {BrowserModule} from '@angular/platform-browser';
import {AppComponent} from './app.component';
// Other imports are removed
@NgModule({
imports: [BrowserModule, HttpModule, LoginModule, routing],
declarations: [AppComponent],
providers: [
Logger,
LOG_LOGGER_PROVIDERS,
AuthenticationService,
AccountService
],
bootstrap: [AppComponent]
})
export class AppModule {
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.