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

半世苍凉 提交于 2019-12-01 05:16:50

@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

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();
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!