anglarjsはnodejsレスポンスデータを取得する2つの方法です.


最初のソリューション:
Nodejsサービス端末:
router.get('/list', function(req, res) {
    employeeService.queryData(function(data) {
      var v = _.clone(mapping.employeeList);
      v.list = data;
      res.render(mapping.employeeList.view, v);
    });
  });
 
Anglarjsクライアント:
app.controller('EmployeeCtrl', ['$scope', function($scope) {
}]);
 
htmlページ設定データ(swig):
<div class="container" ng-controller="EmployeeCtrl" ng-init="list = {= list|json =}">
  <table class="table table-striped">
    <caption><h1>    (—    )</h1></caption>
    <tr>
      <th>#</th>
      <th>  </th>
      <th>  </th>
      <th>  </th>
      <th>   </th>
      <th>  </th>
      <th>  </th>
      <th>    </th>
    </tr>
    {% for e in list %}
    <tr>
      <td>{= e.id =}</td>
      <td>{= e.e_num =}</td>
      <td>{= e.name =}</td>
      <td>{= e.department =}</td>
      <td>{= e.idcard =}</td>
      <td>{= e.birthday|date('Y-m-d', -480) =}</td>
      <td>{= e.salary =}</td>
      <td>{= e.create_at|date('Y-m-d H:i:s', -480, 'CCT') =}</td>
    </tr>
    {% endfor %}
    <tr ng-repeat="e in list">
      <td>{{ e.id }}</td>
      <td>{{ e.e_num }}</td>
      <td>{{ e.name }}</td>
      <td>{{ e.department }}</td>
      <td>{{ e.idcard }}</td>
      <td>{{ e.birthday|date:'yyyy-MM-dd' }}</td>
      <td>{{ e.salary|currency:'¥' }}</td>
      <td>{{ e.create_at|date:'yyyy-MM-dd HH:mm:ss' }}</td>
    </tr>
  </table>
</div>
 
第二の解決策:
Nodejsサービス端末:
app.get('/employee/data', function(req, res) {
  .....
  res.json(list);
});
 
Anglarjsクライアント:
function EmployeeCtrl($scope, $http) {
  $http.get('/employee/data').success(function(data) {
    $scope.list= data
  })
}