0

By default, I want to load a Home page with signup/login option where there is no header or footer in this page. Once the user logged-in successfully, I am redirecting user to loggedIn.html page where the page has a fixed header, sidebar and footer.

The problem is how to prevent the header, sidebar and footer getting applied when I load Home page.

Stateprovider:

var sidebar = {
    templateUrl: 'views/SideBar.html',
    controller: function ($scope) {
    }
};

$stateProvider
.state('Home', {
    url: "/Home",
    views: {
        sidebar: sidebar, //Commented this line out but didn't work
        content: {
            templateUrl: 'views/Home.html',
            controller: function ($scope) {
            }
        }
    }
})

If you see in the above code, I commented out the line for sidebar view but it is still taking up place for side bar on to Home page

Html:

<div id="wrapper">

    <div ui-view="header"></div>   
    <div ui-view="sidebar"></div>    
    <div ui-view="content"></div>

</div>

<div ui-view="footer"></div>

1 Answer 1

1

Use an ng-if based on $state.current.name so your header div tag would look something like this:

<div ui-view="header" ng-if="$state.current.name!='home'">
Sign up to request clarification or add additional context in comments.

3 Comments

I don't want to apply header, footer and sidebar on home page but rest other pages can have it
Sorry. I changed it to not equal. You get the idea? It should be pretty straightforward.
I'm not sure if you're putting in exactly what I posted or using it as a guideline, but if you did it exactly, change it to ng-if="$state.current.name!='Home'" since that's how your state is defined. You could also just create a variable in your controller and check that with ng-if.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.