When working on my HTML code, I encountered the following:
<div class="form-group">
<button type="submit"
value="submit"
class="btn btn-secondary btn-float">Upload</button>
</div>
</div>
In my TS file, I have the following code snippet:
export class testComponent implements OnDestroy {
ngOnDestroy() {
console.log("Fired ngOnDestroy");
}
onClickSubmit() {
this.subscription = this.service
.create(test, url)
.subscribe(
res => {
console.log('HTTP response', res)
},
err => {
console.log("Error", err)
},
() => console.log('HTTP request completed.')
);
}
}
I am facing an issue where after clicking the button to call the service, my ngOnDestroy() method is not being fired. I am unsure why this is happening and could use some assistance.