出于某种原因,当我使用1个输入参数降级一个简单组件时,我收到以下消息:
(SystemJS)无法解析MyLabelComponent的所有参数:(?)。
没有任何参数的相同组件将正常工作。怎么了?我错过了什么吗?我通过angular.io教程做了关于降级角度2组件在角度1应用程序中工作的内容。
我-label.component.ts
import { Component, OnInit, Input, ElementRef } from '@angular/core';
@Component({
selector: 'my-label',
templateUrl: './my-label.component.html',
styleUrls: ['./my-label.component.css']
})
export class MyLabelComponent implements OnInit {
@Input() text: string;
constructor(private elementRef: ElementRef) { }
ngOnInit() {
}
}
我-label.component.html
<div class="my-label">{{text}}</div>
我-label.component.css
.my-label { color: red; }
app.module.ts
import { MyLabelComponent } from './my-label/my-label.component';
@NgModule({
declarations: [
AppComponent,
MyLabelComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
UpgradeModule
],
entryComponents: [
MyLabelComponent
],
bootstrap: [AppComponent]
})
export class AppModule {}
import * as _angular_ from 'angular';
declare global {
const angular: typeof _angular_;
}
import { downgradeComponent } from '@angular/upgrade/static';
angular.module('myModule')
.directive('myLabel', downgradeComponent({component: MyLabelComponent, inputs: ['text']}) as angular.IDirectiveFactory);