AngularJS Example:
by harsh dand
HTML
<link rel="stylesheet" href="http://twitter.github.com/bootstrap/assets/css/bootstrap.css">
<div ng-app="app">
<div ng-controller="SimpleCtrl">
<my-repeat list="item in items">
{{item.name}}
</my-repeat>
</div>
</div>
JavaScript
var app = angular.module('app',[]).
controller('SimpleCtrl',function($scope) {
$scope.items = [{name:'abc'},{name:'def'},{name:'ghi'}];
}).
directive('myRepeat',function(){
return{
restrict:'E',
link:function(scope, element, attrs) {
var data = '';
var attr = attrs.list;
var arr = attr.split(' ');
debugger;
for(var i in scope[arr[2]]){
data += scope[arr[2]][i];
}
console.log(data);
}
}
});