1
resposta

Error: src/app/photos/photo-list/photo-list.component.html:1:1 - error NG8001:

Error: src/app/photos/photo-list/photo-list.component.html:1:1 - error NG8001: 'app-photo' is not a known element:
1. If 'app-photo' is an Angular component, then verify that it is part of this module.
2. If 'app-photo' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
1 <app-photo
  ~~~~~~~~~~
2     *ngFor="let photo of photos"
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3     [url]="photo.url"
  ~~~~~~~~~~~~~~~~~~~~~
4     [description]="photo.description"  >
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  src/app/photos/photo-list/photo-list.component.ts:6:16
    6   templateUrl: './photo-list.component.html',
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component PhotoListComponent.


Error: src/app/photos/photo-list/photo-list.component.html:3:5 - error NG8002: Can't bind to 'url' since it isn't a known property of 'app-photo'.
1. If 'app-photo' is an Angular component and it has 'url' input, then verify that it is part of this module.
2. If 'app-photo' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

3     [url]="photo.url"
      ~~~~~~~~~~~~~~~~~

  src/app/photos/photo-list/photo-list.component.ts:6:16
    6   templateUrl: './photo-list.component.html',
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component PhotoListComponent.


Error: src/app/photos/photo-list/photo-list.component.html:4:5 - error NG8002: Can't bind to 'description' since it isn't a known property of 'app-photo'.
1. If 'app-photo' is an Angular component and it has 'description' input, then verify that it is part of this module.
2. If 'app-photo' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component.

4     [description]="photo.description"  >
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

  src/app/photos/photo-list/photo-list.component.ts:6:16
    6   templateUrl: './photo-list.component.html',
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Error occurs in the template of component PhotoListComponent.




× Failed to compile.


Está dando falha na compilação e não consigo achar o erro.
1 resposta

Olá Danielly, tudo bem com você?

Peço desculpas pela demora em obter um retorno.

O erro error NG8001: 'app-photo' is not a known element indica que o componente app-photo não é reconhecido ou não está registrado corretamente no módulo do componente PhotoListComponent.

Isso pode ocorrer se você não importar ou declarar o componente app-photo no módulo correspondente. Todavia, sem acesso ao código deste arquivo é incerto dizer o ponto exato de correção do erro, mas, uma sugestão de correção é verificar no arquivo photos.component.ts como está a declaração da propriedade selector e caso esteja outro nome que não seja app-photo , use este nome em seu template. Ou seja, caso esteja selector: 'ap-photos', (na aula está desta forma), em seu template html, use <ap-photos> com um único p.

Além disso, verifique se os nomes dos atributos de entrada @Input de ([url] e [description]) estão corretos e correspondem aos nomes definidos no componente photo (photo.component.ts).

Após fazer essas correções, tente executar novamente o seu projeto. No entanto, caso os erros ainda persistam, peço que me envie seu projeto completo, seja no drive ou no github, para que eu possa te auxiliar de forma mais assertiva. Fico à disposição.

Abraços e bons estudos!

Caso este post tenha lhe ajudado, por favor, marcar como solucionado ✓. Bons Estudos!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software