2017-07-17 57 views
0

我对AngularJS非常新颖。我有两个表,一个有需要采访将变量传递给Json API并显示ng-repeat的响应

// From vol.xslt 
<section id="requested_interviews" class="row"> 
<h3>Unassigned Requests</h3> 
<div class="table-responsive"> 
    <table id="unassigned_table" class="table table-condensed"> 
     <tr> 
      <th>Requested</th> 
      <th>First</th> 
      <th>Last</th> 
      <th>City</th> 
      <th>Region</th> 
      <th>Zip</th> 
      <th>Country</th> 
      <th>Action</th> 
     </tr> 
     <tr ng-repeat="p in prospects"> 
      <td>{{ p.Requested }}</td> 
      <td>{{ p.First }}</td> 
      <td>{{ p.Last }}</td> 
      <td>{{ p.City }}</td> 
      <td>{{ p.Region }}</td> 
      <td>{{ p.Zip }}</td> 
      <td>{{ p.Country }}</td> 
      <td> 
       <button class="btn btn-small btn-default btn-block" ng-click="haversine({{{{p.lat}}}}, {{{{p.lng}}}})">Find Matches</button> 
       <button class="btn btn-small btn-default btn-block" ng-click="viewProspectDetais()">Prospect Details</button> 
      </td> 
     </tr> 
    </table> 
</div> 

人名单当用户点击查找匹配按钮时,半正矢函数被调用,它通过人的纬度和经度成它和API会在那个人的面积志愿者响应:

// From controller 
// Volunteer enpoint 
$scope.haversine = function(lat, lng) { 
    $http.get(-- redact api url --).then(function(response) { 
     $scope.volunteers = response.data.row; 
    }); 
}; 

现在,该功能被触发时,它应该更新的观点,我认为这是我有什么麻烦:

// From vol.xslt 
<section id="potential_volunteers" class="row"> 
<h3>Potential Volunteers</h3> 
<table class="table table-hover table-condensed"> 
    <tr> 
     <th>First</th> 
     <th>Last</th> 
     <th>Street</th> 
     <th>Street 2</th> 
     <th>Street 3</th> 
     <th>City</th> 
     <th>Region</th> 
     <th>Zip</th> 
     <th>Country</th> 
     <th>Action</th> 
    </tr> 
    <tr ng-repeat="v in volunteers"> 
     <td>{{ v.First }}</td> 
     <td>{{ v.Last }}</td> 
     <td>{{ v.Street_1 }}</td> 
     <td>{{ v.Street_2 }}</td> 
     <td>{{ v.Street_3 }}</td> 
     <td>{{ v.City }}</td> 
     <td>{{ v.Region }}</td> 
     <td>{{ v.Postal }}</td> 
     <td>{{ v.Country }}</td> 
     <td> 
      <button class="btn btn-small btn-default btn-block" ng-href="assignInterview()">Assign</button> 
      <button class="btn btn-small btn-default btn-block" ng-href="viewVolDetails()">Volunteer Details</button> 
     </td> 
    </tr> 
</table> 

我已经验证端点的作品,而我的变量正确显示出来的按钮内(XSLT要求我使用的角度变量双括号)。

谢谢!

+0

尝试ng-click =“haversine(p.lat,p.lng) – Vivz

+0

没有运气,变量显示为字面p.lat,没有花括号的p.lng – tonyweed

回答

1

答案是更改应用程序本身的角度变量的开始和结束符号。我想XSLT不喜欢解析{{}}字符。

改变我的应用程序声明

var app = angular.module('volApp',[]).config(function($interpolateProvider){ 
    $interpolateProvider.startSymbol('[[').endSymbol(']]'); 
}); 

和所有{{[[}}]]固定的问题。