Refresh specific page with Angular, Express and Jade (using html5mode)

后端 未结 2 899
忘掉有多难
忘掉有多难 2021-01-12 22:27

I\'m trying to refresh a page and execute client route to open a template inside ng-view

Index.jade

extends layouts/default

block c         


        
相关标签:
2条回答
  • 2021-01-12 22:57

    @Scymex help me to find this issue:

    For anybody who might be using Jade, here's a quick gotcha: div(ui-view) compiles to <div ui-view="ui-view"></div>. What you need is div(ui-view="").

    So, you can have ui-view inside ng-include, but need do this trick

    Font: https://github.com/angular-ui/ui-router/issues/679

    0 讨论(0)
  • 2021-01-12 23:06

    You're using HTML5 routes with a hashbang fallback. What that means is you want to set your server up so that requests to /cameras/12 redirect to /#!/cameras/12. The server will then render your Angular application, which will detect that it wants to go to your viewCamera state and will rewrite the url on the client.

    You can accomplish this by simply adding the following middleware to your express app:

    app.use(function (req, res, next) {
        res.set('Location', '/#!' + req.path)
           .status(301)
           .send();
    });
    
    0 讨论(0)
提交回复
热议问题