Angular: Empty Fiddle
http://angularjs.org/
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-controller="appController">
<foo items="Items"></foo>
</div>
JavaScript
var myApp = angular.module('myApp',[]);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
function MyCtrl($scope) {
$scope.name = 'Superhero';
}
myApp.directive('foo', function () {
return {
restrict: 'E',
scope: {
items: '=',
},
template:" <a data-ng-repeat='item in items'><br/>{{item.name}}</a>",
controller: function ($scope) {}
}
});
myApp.controller("appController", function ($scope) {
$scope.Items = [{
"id": 1,
"name": "aaaa"
}, {
"id": 2,
"name": "bbbb"
}]
});