When working with an AngularJS directive, the templateUrl
parameter is dynamically specified.
'templates/' + content_id + '.html'
I am looking for a way to handle situations where the value of content_id
may not be valid or result in a 404 error when trying to load the corresponding template. In such cases, I want to load templates/404.html
instead.
Can someone guide me on how to achieve this?
Edit: Some answers have mentioned using a response error interceptor. How can I differentiate responses related to loading these specific templates?