【问题标题】:AngularJS - Google maps ui-sref inside of a markerAngularJS - 谷歌在标记内映射 ui-sref
【发布时间】:2015-10-16 22:07:38
【问题描述】:

您好,我有角形的谷歌地图,我正在尝试使用按钮制作自定义 marker.content 以到达另一条路线。我正在像这样设置 merkers 服务

this.setMarker = function (item, map) {
    var position = new google.maps.LatLng(item.loc[1], item.loc[0]);
    bounds.extend(position);

    var marker = new google.maps.Marker({
        map: map,
        position: position,
        title: item.name,
        icon: iconBase + 'basic_pin.png'
    });

    marker.content = '<div class="infoWindowContent">' +
    '<div class="author">' + item.user.name + '</div>' +
    '<div class="horizontal">' +
    '<dl>' +
    '<dt>created:</dt>' +
    '<dd class="ng-binding">'  + $filter('dateFormat')(item.created_at)  +'</dd>' +
    '<dt>tracks:</dt>' +
    '<dd class="ng-binding">' + item.tracks.length + '</dd>' +
    '<dt>type:</dt>' +
    '<dd class="ng-binding">' + utilsFactory.getPlaylistType(item.settings.is_private,item.settings.is_yoobox,item.settings.is_locked) + '</dd>' +
    '</dl>' +
    '</div>' +
    '<div class="pink_button enter-play">                ' +
    '<a ui-sref="detailSite({playlistID: item._id})" ng-show="false">play</a>' +
    '</div>'+
    '</div>';

    return marker;
};

问题在于 ui-sref 不像其他角度指令那样工作。有谁知道这个的解决方案吗?

【问题讨论】:

    标签: angularjs google-maps google-maps-api-3 angular-ui-router angularjs-service


    【解决方案1】:

    你必须使用 $compile 服务。

     marker.content = '<div class="infoWindowContent">' +
        '<div class="author">' + item.user.name + '</div>' +
        '<div class="horizontal">' +
        '<dl>' +
        '<dt>created:</dt>' +
        '<dd class="ng-binding">'  + $filter('dateFormat')(item.created_at)  +'</dd>' +
        '<dt>tracks:</dt>' +
        '<dd class="ng-binding">' + item.tracks.length + '</dd>' +
        '<dt>type:</dt>' +
        '<dd class="ng-binding">' + utilsFactory.getPlaylistType(item.settings.is_private,item.settings.is_yoobox,item.settings.is_locked) + '</dd>' +
        '</dl>' +
        '</div>' +
        '<div class="pink_button enter-play">                ' +
        '<a ui-sref="detailSite({playlistID: item._id})" ng-show="false">play</a>' +
        '</div>'+
        '</div>';
    
        var compiledContent = $compile(marker)($scope);
    
        return compiledContent[0];
    

    这里有文档$compile

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-04
      • 2012-07-09
      • 1970-01-01
      • 2011-12-22
      • 1970-01-01
      • 2014-05-16
      • 2015-10-30
      相关资源
      最近更新 更多