$urlRouterProvider.otherwise('/'); conflicting with Mean-seo

时间:2015-07-31 19:30:40

标签: angularjs angular-ui-router mean meanjs

I am trying to implement Mean-seo and it seems to be working except every time it redirects to home page.

http://localhost:3333/?_escaped_fragment_=/contact-us flashes the contact-us page then redirects to home page.

If I remove

$urlRouterProvider.otherwise('/');

It shows the contact us page but then the home page is just blank.

1 个答案:

答案 0 :(得分:0)

这似乎解决了我的问题。使用这个

    $urlRouterProvider.otherwise(function ($injector, $location) {
       //what this function returns will be set as the $location.url
        var path = $location.absUrl();
        if (path.indexOf('_escaped_fragment_') === -1) {
            //instead of returning a new url string, I'll just change the $location.path directly so I don't have to worry about constructing a new url string and so a new state change is not triggered
            return '/';
        }
        // because we've returned nothing, no state change occurs
    });

而不是

  

$ urlRouterProvider.otherwise(' /&#39);