user2516179
user2516179

Reputation: 21

Angular js dynamic tags in template

var template ='<div id="'+'inst'+id+'" ng-click="setCurrentId('+id+')" >'+
        '< {{$scope.somevariable}} data-role="listview" >'+
        '<li><a href="acura.html">Acura</a></li>'+
        '<li><a href="audi.html">Audi</a></li>'+
        '<li><a href="bmw.html">BMW</a></li>'+
        '</{{$scope.somevariable}}>'+
        '</div>';

in the above code i want something like $scope.somevariable to be replaced by ul or ol but unfortunately this doesnt work

can someone tell me how to create dynamic tags using angular js?

Note: attributes like data-role maybe dynamic (i.e may or maynot exist).. so as such i cannot use ng-switch

Upvotes: 2

Views: 888

Answers (1)

EpokK
EpokK

Reputation: 38092

Use ngSwitch or ngShow directives to change content.

ng-switch

ng-show

Upvotes: 1

Related Questions