javascript - AngularJS - inject string from model to HTML's tag name -



javascript - AngularJS - inject string from model to HTML's tag name -

is possible inject string html's tag name angular?

something this:

<div ng-repeat="type in types"> <bettype-{{type.id}}></bettype-{{type.id}}> </div>

the output need is:

<bettype-1></bettype-1> <bettype-2></bettype-2>

i using polymer (this way creating custom html tags).

i think best solution create directive creates custom elements, like:

.directive('bettype', function($compile) { homecoming { restrict: 'e', compile: function($element, $attr) { homecoming function($scope, $element, $attr) { // create new element here $attr.number var number = $attr.number, element = angular.element('<bettype-'+number+'></bettype-'+number+'>'); // replace newly created element $element.replacewith(element); $compile($element)($scope); } } } });

not sure if work, that's way go...

note: don't think it\s thought have dashed separated elements bettype-1..

javascript html angularjs

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -