No meu código tudo está carregando perfeitamente, não aparece nenhum erro, mas as fotos não carregam. Todos os outros componentes abrem normalmente. Alguém sabe o que pode ser?
App.routing.module.ts
import { NgModule } from "@angular/core";
import { RouterModule, Routes } from "@angular/router";
import { NotFoundComponent } from "./errors/not-found/not-found.component";
import { PhotosListComponent } from "./photos/photos-list/photos-list.component";
import { PhotosFormComponent } from "./photos/photos-form/photos-form.component";
const routes: Routes = [
{path: 'photos', component: PhotosListComponent},
{path: 'form', component: PhotosFormComponent},
{path: '**', component: NotFoundComponent}
];
@NgModule({
imports: [
RouterModule.forRoot(routes)
],
exports: [RouterModule]
})
export class AppRoutingModule{}
App.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { PhotosModule } from './photos/photos.module';
import { AppRoutingModule } from './app.routing.module';
import { ErrorsModule } from './errors/errors.module';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
PhotosModule,
AppRoutingModule,
ErrorsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
Photos.module.ts
import { NgModule } from '@angular/core';
import { HttpClientModule } from '@angular/common/http';
import { CommonModule } from '@angular/common';
import { PhotoComponent } from './photo/photo.componet';
import { PhotosListComponent } from './photos-list/photos-list.component';
import { PhotosFormComponent } from './photos-form/photos-form.component';
@NgModule({
declarations: [
PhotoComponent,
PhotosListComponent,
PhotosFormComponent
],
imports: [
HttpClientModule,
CommonModule
]
})
export class PhotosModule{}
Photo-list.component.ts
import { Component, OnInit } from '@angular/core';
import { Photo } from '../photo/photo';
import { PhotoService } from '../photo/photo.service';
@Component({
selector: 'app-photos-list',
templateUrl: './photos-list.component.html',
styleUrls: ['./photos-list.component.css']
})
export class PhotosListComponent implements OnInit {
photos: Photo[] = [];
constructor (private photoService: PhotoService){}
ngOnInit(): void{
this.photoService
.listFromUser('photos')
.subscribe(photos => this.photos = photos);
}
}