I'm building the outline of an app using ui-router. I've defined the states and it seems to work, but I can't help but feel there might be a better way in terms of best practice.
My states:
- 'main' is an abstract state with a header, footer, and a middle content area.
- 'main.home' is what comes up by default. The content file 'home.tpl.html' is a sort of splash page with srefs to other areas of the app, like 'main.wizard.step1'.
- 'main.wizard' is an abstract state representing a multi step info gathering wizard.
- 'main.wizard.step1', 'main.wizard.step2' are steps in the wizard
What I'm doubting is my use of the 'views' object having values of "@" and "". Does this look reasonable, or would you do something else?
$urlRouterProvider.otherwise('/');
var app = {
name: 'main',
abstract: true,
url: '',
views: {
'header': {
templateUrl: 'header.tpl.html'
},
'footer': {
templateUrl: 'footer.tpl.html'
}
}
};
var home = {
name: 'main.home',
url: '/',
views: {
"@": {
templateUrl: 'home/home.tpl.html'
}
}
};
var wizard = {
name: 'main.wizard',
abstract: true,
url: '/wizard',
views: {
"@": {
templateUrl: 'wizard/wizard.tpl.html'
}
}
};
var step1 = {
name: 'main.wizard.step1',
url: '/step1',
views: {
"": {
templateUrl: 'wizard/step1.tpl.html'
}
}
};
/** repeat similarly for step2, step3 & step 4 **/
$stateProvider.state(app);
$stateProvider.state(home);
$stateProvider.state(wizard).state(step1).state(step2).state(step3).state(step4);