written code in angualr component to get the data from service every 10 sec on ngonit ,now I wanted to stop the interval running for every 10 sec post the certain time like 5 min or when data is collected.
Component code.
Getrecords() {
Interval(10000).pipe(
startWith(0),
switchMap(() => this.getservice.getdata())
).subscribe(data => {
this.code = data
});
}