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

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

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

asp.net mvc - breakpoint on javascript in CSHTML? -