如何在phonegap html首页文件中使用sailsjs生成的会话

时间:2015-04-02 10:47:25

标签: android node.js cordova sails.js ejs

这是我的html代码

<html >
<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <link rel="stylesheet" type="text/css" href="css/index.css" />
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css" />
    <title>Hello World</title>
</head>
<body ng-app="socketApp"  ng-controller="NewsController">


<script id="users" type="text/template">


</script>
<script>
  onload = function(){
    var users = document.getElementById('users').innerHTML;
    // var names = ['loki', 'tobi', 'jane'];

    var html = ejs.render("<ul><li><%= session.User.name %></li></ul>", { });
    document.body.innerHTML = html;
  }
</script>


    <script type="text/javascript" src="cordova.js"></script>
    <script type="text/javascript" src="js/sails.io.js"></script>
    <script type="text/javascript">
                io.sails.useCORSRouteToGetCookie = false;
                io.sails.url = 'http://192.168.1.4:1337/';
    </script>
    <!--script type="text/javascript" src="http://cdn.socket.io/socket.io-1.0.3.js"></script-->
    <!--script type="text/javascript" src="js/socket.io.js"></script-->
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript" src="js/ejs.js"></script>
    <script type="text/javascript" src="js/angular.min.js"></script>

    <script type="text/javascript" src="js/app.js"></script>

</body>

来自上面的代码

var html = ejs.render("<ul><li><%= session.User.name %></li></ul>", { });

在这里,我希望在我的cordova前端视图中获得sails服务器创建的会话对象。我尝试了很多次,但我没有获得会话名称。我对科尔多瓦来说很陌生。所以,请帮帮我。

0 个答案:

没有答案