Angular 与构造函数上的@属性的角度绑定

Angular 与构造函数上的@属性的角度绑定,angular,Angular,我有一个组件测试 test.component.ts test.component.html 如何构建这个其他comp并绑定参数值 我尝试使用 <other-comp attr.data-target-panels="{{getParameters()}}"> </other-comp> 及 但是它不起作用。如果您在另一个组件中使用某个组件,并且绑定值属性binding with method,那么方法应该在您使用组件的组件中- A部分- <other-comp

我有一个组件测试

test.component.ts

test.component.html

如何构建这个其他comp并绑定参数值

我尝试使用

<other-comp attr.data-target-panels="{{getParameters()}}">
</other-comp>


但是它不起作用。

如果您在另一个组件中使用某个组件,并且绑定值属性binding with method,那么方法应该在您使用组件的组件中-

A部分-

<other-comp [datatargetpanels]="{{getParameters()}}">
</other-comp>

export class AComponent {

    constructor() {
    }
    public getParameters() {
       return 'Some data';
    } 
}

为什么不使用@Input?我使用的是一个现有的组件,所以更改这个逻辑不是那么容易,所以我需要在这里使用Input。但是@Attributes的真正用途是什么?当我们有一些静态数据时使用它?@JMarques是的,很抱歉,但我不完全确定@attribute的用法,一旦我研究它,它将在这里更新。
export class OtherComponent {

    constructor(@Attribute('data-target-panels') public targetPanels: string
    ) {

    }
}
<other-comp attr.data-target-panels="{{getParameters()}}">
</other-comp>
<other-comp [attr.data-target-panels]="{{getParameters()}}">
</other-comp>
<other-comp [datatargetpanels]="{{getParameters()}}">
</other-comp>

export class AComponent {

    constructor() {
    }
    public getParameters() {
       return 'Some data';
    } 
}
export class otherComponent {
   @Input('datatargetpanels) 'datatargetpanels': string;
}