Here is the code snippet I'm working on within a component:
import { Component, OnDestroy, OnInit } from '@angular/core';
import { interval, Subscription } from 'rxjs';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css'],
})
export class HomeComponent implements OnInit, OnDestroy {
constructor(private firstObsSubscription: Subscription) {}
ngOnInit() {
interval(1000).subscribe((count) => console.log(count));
}
ngOnDestroy() {
this.firstObsSubscription.unsubscribe();
}
}
After defining the component, it gets included in a module and later gets injected into another module.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { HomeComponent } from './home/home.component';
import { UserComponent } from './user/user.component';
import { AppRoutingModule } from './app-routing.module';
@NgModule({
declarations: [AppComponent, HomeComponent, UserComponent],
imports: [BrowserModule, AppRoutingModule],
providers: [],
bootstrap: [AppComponent],
})
export class AppModule {}
It seems like something is not quite right with my code implementation