JavaScript Is there a way to stop Angular from picking up a URL change?

I'm trying to integrate a React application (using react-router) into an existing Angular website. I've wrapped the React app up in an Angular directive which loads scripts and renders the React app into the DOM. It also listens for the $destroy event on the scope to unmount the React app.

Everything's working pretty well apart from links. It seems that Angular is automatically binding to every anchor tag in the DOM which is causing the Angular router to pick up clicks on links in the React app. This causes the React app to be unmounted and reinitialised on every link click - this is obviously poor user experience (especially since the React app contains a video player!).

I added a listener for $locationChangeStart which checks the old and new URLs and calls preventDefault on the event if the two URLs begin with /reactapp. This stops the link from being treated like an Angular route but it creates a problem with the URL. It seems that Angular responds to a prevented default on the $locationChangeStart event by resetting the URL back to what it was before the event was triggered. I've tried calling history.replaceState after this to reset the URL back to what I want (hacky, I know) but Angular seems to recheck and reset the URL on every $digest cycle.

So, my question... is there a way to completely stop Angular from picking up the links from the React app?

Answer:1

I'm getting Model not defined error with below code. I've added underscore, jquery, backbone etc but I can only get object returned with console.log function for jquery only $ Is there a reason why ...

I'm getting Model not defined error with below code. I've added underscore, jquery, backbone etc but I can only get object returned with console.log function for jquery only $ Is there a reason why ...

I'm trying to set up a tabbed navigation bar but it's not hiding the content from the other tabs. On a similar note, creating a new page doesn't work in the same way. It shows the content of the ...

I'm trying to set up a tabbed navigation bar but it's not hiding the content from the other tabs. On a similar note, creating a new page doesn't work in the same way. It shows the content of the ...

  1. jquery mobile tabs swipe
  2. jquery mobile tabs example
  3. jquery mobile tabs default active
  4. jquery mobile tabs
  5. jquery mobile tabs not working
  6. jquery mobile tabs active
  7. jquery mobile tabs w3schools
  8. jquery mobile tabs menu swipe
  9. jquery mobile tabs events
  10. jquery mobile scrollable tabs
  11. jquery mobile navbar tabs example
  12. jquery ui tabs mobile
  13. jquery mobile horizontal scroll tabs

I've got a content-editable <div>. When a correct markdown syntax is entered into the div, I need it to add the correct HTML around the outside, but preserve the markdown characters within. For ...

I've got a content-editable <div>. When a correct markdown syntax is entered into the div, I need it to add the correct HTML around the outside, but preserve the markdown characters within. For ...

Use Case : I have a webpage which shows popovers for some of the functionalities. The popovers can be considered to be a HTML div which is shown when the corresponding button is clicked. And again go ...

Use Case : I have a webpage which shows popovers for some of the functionalities. The popovers can be considered to be a HTML div which is shown when the corresponding button is clicked. And again go ...

  1. change browser back button url
  2. change browser back button behaviour
  3. change browser back to english
  4. change browser back to google
  5. change browser back
  6. javascript change browser back button behavior
  7. change default browser back to internet explorer
  8. change google browser back to english
  9. change my browser back to english
  10. php change browser back button
  11. javascript change browser back button
  12. change default browser back