Ich mag eine eindeutige ID zu jedem div in dieser Richtlinie hinzuzufügen, so dass ich mit welchem Elemente angeben kann, dass Google Maps passieren sollte:Wie können Sie jeder Instanz einer Anweisung eine eindeutige ID hinzufügen?
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)
},
};
}).
Mögliches Duplikat [Richtlinie Vorlage eindeutiger IDs für Elemente] (http://stackoverflow.com/questions/21021951/directive-template-unique-ids-for-elements) –