小编dwr*_*ked的帖子

ng-repeat和string替换表达式值

在使用ng-repeat指令时,我无法找到删除角度表达式中的子字符串的解决方案.

控制器在外部javascript文件中,html如下.

function myController($scope, $http){
  $http.get('http://localhost:3000/people.json').
    success(function(data){
      $scope.persons = data;
    });
}
Run Code Online (Sandbox Code Playgroud)
<table ng-controller="myController" class="table table-striped table-hover">
  <thead class="text-center">
    <th>Name</th>
    <th>ID</th>
    <th>Address</th>
  </thead>
  <tbody>
    <tr ng-repeat="person in persons" class="text-center">
      <td>((person.name}}</td>    
      <td>{{person.id}}</td>
      <td>{{person.address}}</td>
    </tr>
  </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

localhost:3000/people.json页面有几百个JSON对象:

[{name:"John Smith",id:12345,地址:"addr:789 Broadway St"},

...]

我的问题:在地址值中剥离'addr:'子字符串的最有效和/或最简单的方法是什么?我没有对people.json页面的写访问权限.

javascript json node.js express angularjs

0
推荐指数
1
解决办法
5138
查看次数

标签 统计

angularjs ×1

express ×1

javascript ×1

json ×1

node.js ×1