currently working on an application where I am using AngularJS UI routes. After searching couple for hours for my problem on internet, still I am not able to understand how my issue will get resolved. Here is my code which i am using. If anyone can help into this. Then i would be really thankful.
I just wanted to know the code how to define state for ui-view="sidebar" like i have defined for header and footer inside my defaultLayout state. Tried something but not working. Any idea please share.
HTML:
//====index.html=====//
<body ui-view="layout"></body>
//========default.html (nested view inside layout)=============//
<header ui-view="header"></header>
<div class="wrap">
<div id="container">
<div ui-view="alert"></div>
<div ui-view></div>
</div>
</div>
<footer ui-view="footer"></footer>
//=======products.html (another nested view inside empty ui-view in default.html file)========//
<div class="row"><div ui-view="sidebar"></div></div>
JS code:
//=====states I have defined in my route files are=====//
$stateProvider.
state('defaultLayout', {
abstract: true,
views: {
'layout': {
templateUrl: 'views/layouts/default.html'
},
'header@defaultLayout': {
templateUrl: 'views/elements/header.html',
controller: 'HeaderCtrl'
},
'footer@defaultLayout': {
templateUrl: 'views/elements/footer.html',
controller: 'FooterCtrl'
},
'sidebar@defaultLayout': {
templateUrl: 'views/elements/sidebar.html',
controller: 'SidebarCtrl'
},
'alert@defaultLayout': {
templateUrl: 'views/layouts/alert.html',
controller: 'AlertCtrl'
}
}
})
.state('home', {
url: '/',
templateUrl: 'views/pages/home.html',
controller: 'HomeCtrl',
parent: 'defaultLayout'
})
.state('checkout', {
url: '/pages/checkout',
templateUrl: 'views/pages/checkout.html',
controller: 'HomeCtrl',
parent: 'defaultLayout'
});