Angular - Template-expanding directive

by Zuhaib Siddiqui

HTML

<div ng-app="myApp" ng-controller="Controller">
  <div my-customer></div>
</div>

JavaScript

angular.module('myApp', [])
.controller('Controller', ['$scope', function($scope) {
  $scope.customer = {
    name: 'Naomi'\n,
    address: '1600 Amphitheatre'
  };
}])
.directive('myCustomer', function() {
  return {
    template: 'Name: {{customer.name}} Address: {{customer.address}}'
  };
});