angularjs - Set Id Attribute of element to variable from directives controller -


update #2: using template: '<div id="{{vm.divid}}"></div>' works fine , variable input template , other times doesn't work , instead of using variable id set id="{{vm.divid}}". still haven't figured out making work , not others

original post

i have simple directive needs element in template have id set dynamically. figured simple no matter variable doesn't interpolate.

i have tried setting id this, template: '<div id="{{vm.divid}}"></div>' template: '<div ng-attr-id="{{vm.divid}}"></div> , number of variations of 2 none seem work.

here directive:

.directive('gmap', function() {     return {         restrict: 'e',         scope: {             'options': '='         },         transclude: true,         controlleras: 'vm',         bindtocontroller: true,         controller: function(mapservice) {             console.log(this.options.mapid); // logs specified id             this.divid = this.options.mapid;         },         template: '<div id="{{vm.divid}}"></div><div ng-transclude></div>'     }; }) 

update: cut , paste code plunkr , works fine there must else outside directive have no idea start


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -