Last Updated: September 09, 2019
·
1.023K
· yassershaikh

AngularJs Directives For Beginners

At a high level, directives are markers on a DOM element (such as an attribute, element name, comment or CSS class) that tell AngularJS's HTML compiler ($compile) to attach a specified behavior to that DOM element or even transform the DOM element and its children.

HTML Markup

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

Angular Js

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

You can also check this site called careerbaba for all the latest interview questions and interview experiences

1 Response
Add your response

How is the last link related to anything?

over 1 year ago ·