加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AngularJS – Google将ui-sref映射到标记内

发布时间:2020-12-17 16:56:40 所属栏目:安全 来源:网络整理
导读:嗨,我有角度的谷歌地图,我正在尝试使用按钮进行自定义marker.content到达另一条路线.我正在设置像这样的服务 this.setMarker = function (item,map) { var position = new google.maps.LatLng(item.loc[1],item.loc[0]); bounds.extend(position); var marke
嗨,我有角度的谷歌地图,我正在尝试使用按钮进行自定义marker.content到达另一条路线.我正在设置像这样的服务

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与其他角度指令不同.有谁知道这个解决方案?

解决方法

你必须使用$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_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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读