我是 AngularJS 新手。我正在尝试使用 AngularJS 指令的模板显示图像,并在单击图像时希望在图像上放置一个标记。我不知道为什么它不起作用。
第一个指令:
directive('hello', function() {
return {
template: '<img id="map" src="http://www.lonelyplanet.com/maps/asia/india/map_of_india.jpg" />',
link: function(scope, element, attrs) {
$('#map').click(
function(e) {
$('#marker').css('left', e.pageX).css('top', e.pageY).show();
}
);
},
};
});
html代码
<hello>
<img id="marker" src="http://maps.google.com/mapfiles/ms/micons/blue.png" style="display: none; position: absolute;" />
</hello>