简体   繁体   中英

Angular Routes and Rails Partials

Hi have an angluar route that looks like this

app.config ($routeProvider, $locationProvider) ->
  $locationProvider.html5Mode(true);
  $routeProvider.when("/",
    {
      templateUrl: "assets/pages/partials/home_controls.html"
      controller: MapCtrl
    }
  ).when("/products/business",
    {
      templateUrl: "../assets/pages/partials/business_controls.html"
      controller: MapCtrl
    }
  ).when("/products/search",
    {
      templateUrl: "../assets/pages/partials/search_controls.html"
      controller: MapCtrl
    }
  )

Its works really well. And loads the partials inside an

When these pages load from the address input or page refresh they load fine

However if I have a link controlled by a Rails view for example, it only loads the AngularJS Partial and does not change the Rails page. For example:

<%= render :partial => "pages/partials/map"%>

The Angular code is loading inside that partrial, other surrounding layouts control the Nav's etc...

Its odd because a link to a page only loads Angular but a fresh address loads everything okay

Maybe it happens because of

$locationProvider.html5Mode(true);

Are you sure your browser realy asks your rails server to give it the page?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM