Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It sounds like you need to have the footer outside the <code>ng-view</code> element in order to handle the layout you are wanting. I'll leave the layout/CSS to you but the following example demonstrates a way to communicate with the directive if it were to live outside ng-view.</p> <p>Here's a plunkr (<a href="http://plnkr.co/edit/NpoIrOdfvn9XZiXY9YyV?p=preview" rel="nofollow">http://plnkr.co/edit/NpoIrOdfvn9XZiXY9YyV?p=preview</a>).</p> <p><strong>HTML</strong></p> <pre><code>&lt;body ng-app="someApp"&gt; &lt;div ng-view&gt;&lt;/div&gt; &lt;footer-directive&gt;&lt;/footer-directive&gt; &lt;/body&gt; </code></pre> <p><strong>JS</strong></p> <pre><code>angular.module('someApp', []).config(function($routeProvider) { $routeProvider.when('/', { template: '&lt;p&gt;template&lt;/p&gt;', controller: 'SomeCtrl' }).otherwise({ redirectTo: '/' }); }).service('broadcastService', function($rootScope, $log) { this.broadcast = function(eventName, payload) { $log.info('broadcasting: ' + eventName + payload); $rootScope.$broadcast(eventName, payload); }; }).controller('SomeCtrl', function(broadcastService, $log, $timeout) { //fire off showfooter message broadcastService.broadcast('ShowFooter', { some: 'data' }); // wait 3 seconds and hide footer $timeout(function() { //fire off hide message broadcastService.broadcast('HideFooter'); }, 3000); }).directive('footerDirective', function(broadcastService, $log) { return { restrict: 'E', link: function(scope, elm, attr) { elm.hide(); scope.$on('ShowFooter', function(payload) { $log.info('payload received'); $log.debug(payload); // assuming you have jQuery elm.show(); }); scope.$on('HideFooter', function() { // assuming you have jQuery elm.hide(); }); } } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload