0

I searched around and found some stuff for using AngularJS integration with rails, angular routing, the whole nine, but I want to use the default rails routing and just use directives. No one seems to want to do this, or its not possible without overriding turbolinks entirely.

Whenever I navigate around, my directives don't stick, they flash off, never to return. I've read this is a turbolinks issue and bootstrapping the app is required on the page:load event, but is there no way to keep my directives on screen through page changes?

1 Answer 1

1

Turbolinks attempt to optimize rendering of pages and would conflict with normal bootstraping of AngularJS.

If you are using Turbolinks in some places of your app and some parts use Angular. I propose this elegant solution:

Each link to a page that is angularapp (where you use ng-app="appname") should have this attribute:

<a href="/myapp" data-no-turbolink>Say NO to Turbolinks</a>.

The second - mentioned on Stackoverflow is explicitly reloading/bootstrapping every ng-app by handling page:load event. I would that's intrusive, not to mention you're potentially loading something that isn't on a page hence wasting resources.

I've personally used the above solution.

Hope it helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.