Bom dia, tudo bem ? Eu estou usando o Angular 14 e seguindo o tutorial do professor continua dando erro de NullInjectorError
Estou usando outra API
Service
import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
const API = 'https://rickandmortyapi.com/api'
export interface Response{
result:Array<PersonagemItem>
}
export interface PersonagemItem{
name:string,
image:string,
}
Injectable({ providedIn: 'root' })
export class PhotoService{
constructor (private http:HttpClient){
}
listfromCharacter(character:string){
return this.http
.get<Response>(API+'/character')
}
}
App component
import { Component } from '@angular/core';
import { PersonagemItem,Response, PhotoService } from './photos/photo/photo.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
character:PersonagemItem[]=[]
constructor (photoService:PhotoService){
photoService
.listfromCharacter('all')
.subscribe(characters=>this.character = characters.result)
}
}