【问题标题】:How sails controller can route to angularjs page?Sails 控制器如何路由到 angularjs 页面?
【发布时间】:2016-04-20 13:49:04
【问题描述】:

我有一个 Sails 应用程序,我可以在控制器内使用 res.redirect() 到 angularjs 主页吗?

【问题讨论】:

    标签: angularjs sails.js


    【解决方案1】:
    You can use following options in your angularjs controller.
    1) $location.path("path");
    2) $location.url("path");
    3) $window.location("path");
    

    更多详情可以参考link 如果你使用 ui-route 那么你可以使用 $state.go("path");

    【讨论】:

    • 哦,我的意思是从sails.js 控制器到angularjs,而不是从angularjs 到sails.js。谢谢。
    【解决方案2】:

    是的,你可以use 像这样。

    module.exports ={
       index: function (req, res) {
          return res.redirect('/');
        }  
    }
    

    http://sailsjs.org/documentation/reference/response-res/res-redirect

    【讨论】:

    • 谢谢,我去看看。
    猜你喜欢
    • 2020-02-29
    • 1970-01-01
    • 2011-05-08
    • 2014-01-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-28
    • 1970-01-01
    相关资源
    最近更新 更多