0

I noticed that in angular you can define inputs inside the @component decorator

@Component({
   selector: 'my-component',
   changeDetection: ChangeDetectionStrategy.OnPush,
   template: '<ng-content></ng-content>',
   inputs: ['first', 'last', 'middle']
})
export class ...

But how can one now type the inputs, which you simply can do with @Input

@Input() first: string;
1

1 Answer 1

1

Try this

inputs: ['name', 'id: number'],

This is a string array by default. Now, create your property in class as

id: number (without @Input)

Sign up to request clarification or add additional context in comments.

1 Comment

thanks a lot, thats it. But your example is incorrect. In that inputs array you don't define a type, but an alias only, so it will look like this inputs: ['name', 'id: account-id']

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.