Angularjs ng在$compile信息窗口中单击不工作
嗨,我在我的angular应用程序中使用谷歌地图。我需要设置按钮(添加到购物车)在信息窗口,做添加文章选择从地图(标记)。我添加了$compile,但是ng click仍然不起作用。试图在谷歌上找到解决方案,但仍然存在同样的问题。这是我的ctrl键,带有html和按钮“addToCart()”。我尝试制作plunker,但我的应用程序有很多部分,而且制作plunker、sry和thnx非常复杂Angularjs ng在$compile信息窗口中单击不工作,angularjs,google-maps,Angularjs,Google Maps,嗨,我在我的angular应用程序中使用谷歌地图。我需要设置按钮(添加到购物车)在信息窗口,做添加文章选择从地图(标记)。我添加了$compile,但是ng click仍然不起作用。试图在谷歌上找到解决方案,但仍然存在同样的问题。这是我的ctrl键,带有html和按钮“addToCart()”。我尝试制作plunker,但我的应用程序有很多部分,而且制作plunker、sry和thnx非常复杂 marker.content = '<div class="iw-container" sty
marker.content = '<div class="iw-container" style="color: #000;"><button type="button" on-click="addToCart(info)">Add to cart</button>'
+
'<div class="iw-content">'
+
'<b>'
+
'Serial number: '
+
'</b>'
+
info.serial_n
+
'</div>'
+
'<div class="iw-content">'
+ '<b>'
+
'Description: '
+
'</b>'
+
info.desc
+
'<b>'
+
'</div>'
+
'<div class="iw-content">'
+
'Last report: '
+
'</b>'
+
info.last_report
+
'<b>'
+
'</div>'
+
'<div class="iw-content">'
+
'Created: '
+
'</b>'
+
info.created_at
+
'</div>'
+
'<div class="iw-content">'
+
'<img border="0" float="left" src="">'
+
'<img border="0" float="right" src="">'
+
'</div>'
+
'</div>';
var compiled = $compile(marker.content)($scope);
var infoWindow = new google.maps.InfoWindow({
content: compiled[0]
});
google.maps.event.addListener(marker, 'click', function () {
infoWindow.setContent(this.content);
infoWindow.open($scope.map, marker);
});
$scope.markers.push(marker);
}
marker.content='添加到购物车'
+
''
+
''
+
'序列号:'
+
''
+
info.serial\n
+
''
+
''
+ ''
+
'说明:'
+
''
+
信息描述
+
''
+
''
+
''
+
“上次报告:”
+
''
+
info.last_报告
+
''
+
''
+
''
+
'已创建:'
+
''
+
info.created_在
+
''
+
''
+
''
+
''
+
''
+
'';
var compiled=$compile(marker.content)($scope);
var infoWindow=new google.maps.infoWindow({
内容:已编译[0]
});
google.maps.event.addListener(标记,'click',函数(){
infoWindow.setContent(this.content);
infoWindow.open($scope.map,marker);
});
$scope.markers.push(marker);
}
按钮的声明方式看起来无效,至少objectinfo
无法传递到指定的函数中。尝试从以下位置更改按钮声明:
<button type="button" on-click="addToCart(info)">Add to cart</button>
Thnx感谢您的帮助和时间。我使用你的解决方案时做了一些修改,工作起来很有魅力
<button type="button" ng-click="addToCart(' + i + ')">Add to cart</button>