Skip to content

help(matBadge): Getting error Type 'number' is not assignable to type 'string' with strictTemplates flag #20326

@gauravsoni119

Description

@gauravsoni119

What are you trying to do?

I am using the matBadge directive and I need to pass some default value to the matBadge(for example 0, 7, etc). But as I enabled the strictTemplates flag in my tsconfig.json, I am getting an error
Type 'number' is not assignable to type 'string'
since the @Input matBadge is expecting a string.

I can fix it by doing something like:-
@Input() badgeValue = '7';
and then pass it to matBadge directive, but I feel like this is annoying.

Can anyone help me with this?

Environment

  • Angular: 9.0.2
  • Material: 9.2.0
  • Browser(s): Chrome
  • Operating System: Ubuntu

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: material/badge

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions