mercredi 3 décembre 2014

How can i use ng-repeat to generate custom html tag or directive?


Vote count:

0




I try to create some custom tag using angularjs with ng-repeat but its not work, its put tag name in double qutation marks.


Good result is: shouldn't show <div> or another tags.


I make a demo version here : http://ift.tt/1wr0m55 or you can use code snippet


my code is:





angular.module('myApp', [])
.controller('MainCtrl', function($scope) {
$scope.items = [
{
"name":"directive1"
},
{
"name":"directive2"
},
{
"name":"div"
}
];
})

.directive("showitems", function(){
return {
restrict: "E",
template: '<div class="item" ng-repeat="item in items"><div class="item-title">{{item.name}}</div><div class="item-body"><{{item.name}}></{{item.name}}></div></div>'
}
});



<script src="http://ift.tt/1mQ03rn"></script>
<div ng-app="myApp" ng-controller="MainCtrl">
<showitems></showitems>
</div>




asked 2 mins ago







How can i use ng-repeat to generate custom html tag or directive?

Aucun commentaire:

Enregistrer un commentaire