Angular: Empty Fiddle

http://angularjs.org/

by boneskull

HTML

<script src="http://code.angularjs.org/1.1.5/angular.min.js"></script>
<script type="text/ng-template" id="company-launcher">
    <h1>Your Company</h1>
    <div ng-show="staff">pick other company</div>
</script>

    <company-launcher company-staff-launcher="false"/>

JavaScript

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


myApp.directive('companyLauncher', function() {
    return {
        restrict:'E',
        scope: {},
        templateUrl: 'company-launcher',
        controller: function($scope, $element, $attrs) {
            $scope.staff = false;
            this.setStaff = function(val) {
                $scope.staff = !!val;
            };
        },
        link: function(scope, element, attrs) {
            console.log('linking 1');
            console.log(scope.staff);
        }
    };        
});

myApp.directive('companyStaffLauncher', function() {
    return {
        restrict: 'A',
        require: 'companyLauncher',
        link: function(scope, element, attrs, companyLauncher) {
            console.log('linking 2');
            companyLauncher.setStaff( scope.$eval(attrs.companyStaffLauncher))
            console.log(companyLauncher.staff);
        }
    };
});