0

将 AngularJS 控制器升级到 Angular 2。

export default {
    template: html,
    bindings: {
        binding1: '<',
        binding2: '<',
        binding3: '<'
    },
    controller: [SomeService, controller]
}

function controller(SomeService) {
    // code
}

我想将其转换为 Angular 2 组件

export class TestComponent implements OnInit {
    constructor(){}
}

如何更换绑定?

4

1 回答 1

1
@Component({
    template: html,
    selector: 'wasnt-shown-in-ngJS-example',
})
export class TestComponent {
    @Input() binding1: number;
    @Input() binding2: string;
    @Input() binding3: Foobar | null;

    constructor(private someSrv: SomeService){
    }

}

这是你要找的吗?

于 2018-12-14T18:42:50.233 回答