Below is a service that can be used to get the previous url from angular router where it is navigated via router or browser’s back...