Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bgimage(){
- return{
- restrict: "E",
- replace: true,
- template: "<div class='bg-image'><img src='img/logo-black.svg'></div>"
- }
- }
- <body ng-app="app">
- <bgimage></bgimage>
- <main ui-view></main>
- </body>
- var self = this;
- self.routeOnDisplayDirective = ['/path', '/path2'];
- self.showDirective = showDirective;
- function showDirective () {
- if (self.routeOnDisplayDirective.indexOf($location.path()) !== -1) {
- return true;
- } else return false;
- }
- <bgimage ng-if="ctrl.showDirective()"></bgimage>
- .run(function($rootScope){
- $rootScope.showBg = function(){
- // страницы где background не будет отображаться.
- var pageName = ['/page_1', '/page_2'];
- var location = window.location.pathname;
- if(pageName.indexOf(location) == -1)
- return true
- else
- return false
- }
- })
- <body ng-app="app">
- <bgimage ng-if='showBg()'></bgimage>
- <main ui-view></main>
- </body>
Add Comment
Please, Sign In to add comment