javascript - How to set different ID's in Angular for HTML elements added with angular.append -


having code in directive holds leaflet map:

angular.element($elem[0]).append(angular.element('<div id="map" style="width: 100%; height: calc(100% - 25px); border: 1px solid #ccc"></div>'));  map = new l.map('map', {layers: [osm], center: new l.latlng(center[0], center[1]), zoom: 10}); 

how set different id's each copy of directive add? way have several copies of map on screen, instead of 1 have @ moment. thank you.

you try that:

$scope.mapcount=0;  angular.element($elem[0]).append(angular.element('<div id="map'+ mapcount++ +'" style="width: 100%; height: calc(100% - 25px); border: 1px solid #ccc"></div>')); 

i hope helps.


Comments

Popular posts from this blog

php - Passing multiple values in a url using checkbox -

compilation - PHP install fails on Ubuntu 14 (make: *** [sapi/cli/php] Error 1) PHP 5.6.20 -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -