Advertisement
mhyusuf

Create Custom Directive

Sep 17th, 2015
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.64 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3.     <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
  4.  
  5.     <body ng:app="app6" >
  6.         <div ng-controller="xCon">
  7.             <div my-customer></div>
  8.         </div>
  9.     </body>
  10.  
  11.     <script>
  12.         angular.module('app6', [])
  13.         .controller('xCon', ['$scope', function($scope) {
  14.           $scope.customer = {
  15.             name: 'Naomi',
  16.             address: '1600 Amphitheatre'
  17.           };
  18.         }])
  19.         .directive('myCustomer', function() {
  20.           return {
  21.             templateUrl: 'my-customer.html' // template terpisah
  22.           };
  23.         });
  24.     </script>
  25.    
  26. </html>
  27.  
  28. //Lalu buat file ini my-customer.html:
  29.  
  30. Name: {{customer.name}} Address: {{customer.address}}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement