1

I can go my app and change pages without an issue. Using the back button is also not a problem...unless I return to the point in the history where I first opened the application. So, index -> pg 1 -> index -> pg 2 allows me to press the back button twice, returning me to the index and then pg 1. The next back click yields this error and the ng-view does not load:

"WARNING: Tried to load angular more than once."

It's clear that usually the back button is just using the $routeProvider which looks like this for me (more routes than shown, but the structure is the same)

  .config(['$routeProvider',
    function($routeProvider) {
      $routeProvider.
        when('sampleUrl', {
          templateUrl: 'sampleTemplate',
          controller: 'sampleCtrl'
        }).
        otherwise({
          redirectTo: 'sampleUrl'
        });
    }]);

However the last back button no longer is merely using just the $routeProvider to update the ng-view but also reloading the Rails layout that holds the ng-view. The general structure of the layout is as follows

%html{ 'ng-app' => 'myApp' }
  %body#dashboard(ng-controller='baseCtrl')
     navbar stuff
     %section.clearfix.aaux(ng-view)
javascript include tag for rails asset pipeline

My Rails root looks like this

  root "dashboard/patients#index"

Here's what I've looked at/contemplated so far:

Tried to Load Angular More Than Once

Irrelevant. My templateUrl is correct for all routes; unless I click back to the beginning all is fine and dandy.

This

"But if your templateUrl is wrong, then it will cause a recursion that reloads index.html loading angular (and everything else) over and over."

might be relevant, as it is reloading the page with ng-app on it which I believe is also what index.html is in their app. But from what I've seen of Rails apps integrating with Angular it's common practice to put the

%html{ 'ng-app' => 'ekoApp' }

on the layout.

WARNING: Tried to load angular more than once. Angular JS

I definitely only have one ng-app in my application, but it IS being loaded twice. Regardless, without an extra ng-app to delete, this solution wasn't particularly helpful.

My most recent thought is that there might be something funky with having a root to an empty html page and using my layout to render the ng-view rather than a Rails view.

Any ideas?

Edit:

Took everything in the body into the index.html and then within the layout just did

= yield

The situation remains exactly the same.

1 Answer 1

3

Removing turbolinks solved the problem. I had assumed it was fine since this was the only weird error I was getting, but guess not. I'm confused as to why it was causing this problem however, so any explanation that covers that thoroughly I'll mark as the right answer.

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.