Angular.js Example: Directive

by spechackers

HTML

<div ng-app="MyApp">
    <my-footer legal terms contact></my-footer>
</div>

JavaScript

var app=angular.module('MyApp', []);

app.directive('myFooter', function () {
    return {
        restrict: 'E',
        scope: false,
        link: function (scope, element, attrs) {
            scope.terms = typeof attrs.terms != 'undefined';
            scope.legal = typeof attrs.legal != 'undefined';
            scope.contact = typeof attrs.contact != 'undefined';
            console.log("scope.terms", "scope.legal", "scope.contact", scope.terms, scope.legal, scope.contact)
        }
    }
})