2017-08-19 43 views
0

我想獲得使用谷歌地點API他們的照片的位置列表。 我將響應存儲在變量vm.locationList中。在我看來,我正在迭代這個變量來顯示位置列表。 以下是代碼在谷歌API的地方照片請求在img src

<div ng-repeat = "(key, value) in vm.locationList"> 
<div class="panel panel-primary"> 
    <div class="panel-body"> 
    <div class="col-md-2"> 
     <div class="pull-left thumbnail"> 
     <span ng-if="vm.getPhotos"> 
     <img src="https://maps.googleapis.com/maps/api/place/photo?maxwidth=150&photoreference={{value.photos[0].photo_reference}}&key=API_KEY" class="img-responsive" style="margin-right:10px;"> 
     </span> 
     </div> 
    </div> 
    <div class="col-md-10"> 
     <h4><b>{{value.name}}</b></h4> 
     <p><i class="fa fa-map-marker" style="color:red"></i>&nbsp;{{value.vicinity}}</p> 
     <p> open now: {{value.opening_hours.open_now}}</p> 
    </div> 
    <div ng-repeat = "type in value.types"> 
     <p style="float:left;width:20%" class="tags">{{type}}<p> 
    </div> 
    </div> 

</div> 

我們拿到我把照片HTTP URL請求img標籤的src屬性。雖然我得到了列表的照片,但我看到控制檯說錯誤的請求錯誤。 以下是我在控制檯

GET https://maps.googleapis.com/maps/api/place/photo?maxwidth=150&photoreference={{value.photos[0].photo_reference}}&key=API_KEY 400() 

收到錯誤這裏是HTTP響應

<title>Error 400 (Bad Request)!!1</title> 

<a href=//www.google.com/><span id=logo aria-label=Google></span></a> 
<p><b>400.</b> <ins>That’s an error.</ins> 
<p>Your client has issued a malformed or illegal request. <ins>That’s all we know.</ins> 

回答

0

好,我已經得到了我在那裏做的錯誤。我使用了Angular的ng-src來代替src屬性。現在它工作正常。綁定不能提前工作。我很困惑,因爲即使裝訂不工作圖像出現。