the code was running fine on angular version 8.3.4 but when i updated it to the latest version of angular ( 9 ) i got the following error
following is t
The two answers above about declaring DatePipe
in providers
should be considered. Today I met this problem (Angular 9) when adding an argument private datePipe: DatePipe
in the constructor of my component without declaring DatePipe
in the module's provider
. After adding DatePipe
in providers
, I have no more the problem.
The constructor :
constructor(private authenticationService: AuthenticationService, private datePipe: DatePipe) {}
@VikasBhardwaj I had same problem in Angular 9 because I have created lobby page and lobby component. In this case, app-lobby is duplicated in pages and components.
@Component({
selector: 'app-feed',
So I have changed page name as lobbies, so the problem is fixed.
Probably you have more than one component with the same selector tag name app-lobby
...
@Component({
selector: 'app-lobby',
...
Please double check to ensure that only one component selector tag name is app-lobby
.
I have an app in angular 9. I had similar problem, but then i realised that i forgot the provider for DatePipe. After that, this error went away... Maybe errors like these won't be happening after some time of angular 9 development.
This error actually has less to do with the tagname app-lobby
.
I encountered this error when I applied multiple component selector on a html tag.
For example: Component 1
@Component({
...
selector: '[my-tooltip]',
...
})
Component 2
@Component({
...
selector: '[my-button]',
...
})
Notice that both of them are angular component yet having a selector like attribute directive.
When you apply both of them on the same tag like below:
<button my-button my-tooltip="Some tooltip">Hover me</button>
Then angular complains about applying 2 components on a single tag. In this case it will complain about button tag, like:
Error: Multiple components match node with tagname button
The solution would be not to use multiple component selector on a single element.
Add DatePipe in the providers.It will work fine.