Guest User

Untitled

a guest
Jul 28th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. function bgimage(){
  2. return{
  3. restrict: "E",
  4. replace: true,
  5. template: "<div class='bg-image'><img src='img/logo-black.svg'></div>"
  6. }
  7. }
  8.  
  9. <body ng-app="app">
  10. <bgimage></bgimage>
  11. <main ui-view></main>
  12. </body>
  13.  
  14. var self = this;
  15.  
  16. self.routeOnDisplayDirective = ['/path', '/path2'];
  17.  
  18. self.showDirective = showDirective;
  19.  
  20. function showDirective () {
  21. if (self.routeOnDisplayDirective.indexOf($location.path()) !== -1) {
  22. return true;
  23. } else return false;
  24. }
  25.  
  26. <bgimage ng-if="ctrl.showDirective()"></bgimage>
  27.  
  28. .run(function($rootScope){
  29.  
  30. $rootScope.showBg = function(){
  31. // страницы где background не будет отображаться.
  32. var pageName = ['/page_1', '/page_2'];
  33. var location = window.location.pathname;
  34.  
  35. if(pageName.indexOf(location) == -1)
  36. return true
  37. else
  38. return false
  39. }
  40. })
  41.  
  42. <body ng-app="app">
  43. <bgimage ng-if='showBg()'></bgimage>
  44. <main ui-view></main>
  45. </body>
Add Comment
Please, Sign In to add comment