我想唯一的ID添加到每个格在这个指令,让我可以指定哪些元素谷歌地图应该通过:如何为指令的每个实例添加一个唯一的ID?
directive('gMap', function(googleMaps){
return{
restrict: 'E',
replace: true,
transclude: true,
template: "<div id="{{unique_ID}}"></div><div ng-transclude></div>",
scope: true,
link: function(scope, element, attrs){
//create the map
var center = googleMaps.makePosition(attrs.centerlat, attrs.centerlong)
//update map on load
var options = googleMaps.setMapOptions(center, attrs.zoom);
scope.map = googleMaps.createMap(options, unique_id)
},
};
}).
[为元素指令模板的唯一ID]的可能的复制(http://stackoverflow.com/questions/21021951/directive-template-unique-ids-for-elements) –