2017-07-17 4 views
0

私はAngularJSの新機能です。ユーザーがに人の緯度と経度を渡し、検索がマッチボタン、半正矢関数が呼び出されると、クリックしたとき、私は2つのテーブルを持って、一つはインタビュー変数を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(']]'); 
}); 

、すべての{{に私のアプリの宣言を変更し、]]から}}は、問題を修正しました。

関連する問題