简体   繁体   中英

How to output javascript string in angularjs as loop array?

How to printout to html(angularjs) 'name' string as loop in the following code?
When I printed overwrited scope array, more than one printed last string.

var createMarker = function (place) {
var request = {
  reference: place.reference
};
var detail = new google.maps.places.PlacesService($scope.map.control.getGMap());
detail.getDetails(request, function(result, status) {
  if (status == google.maps.places.PlacesServiceStatus.OK) {
    $scope.map.markers.push({
      latitude: place.geometry.location.lat(),
      longitude: place.geometry.location.lng(),
      showWindow: false,
      name: result.name,
      phone: result.formatted_phone_number,
      website: result.website,
      html: result.html_attributions[0],
      type: result.types.toString()
    });
    $scope.$apply();


    $ionicLoading.hide();

  }

});

Thanks.

You don't have to write scope in your template, you can have your name string in the repeat just by using

<ul> 
  <li ng-repeat="m in map.markers">
    {{m.name}}
  </li>
</ul>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM