quickstart-ng2
quickstart-ng2 copied to clipboard
Simplified state definition
If I have a state definition like this (shortened for readibility):
let states = [
{
name: 'app.profile',
url: '/profile',
views: {
$default: {component: ProfileComponent}, // <--- this
'[email protected]': {component: ProfileAboutMeComponent},
'[email protected]': {component: ProfilePhotosComponent},
'help@app': {component: ProfileHelpComponent},
},
},
];
and a ProfileComponent that only has a template with no logic:
@Component({
template: `
<h4>My profile</h4>
<ui-view>
<ui-view name="about_me"></ui-view>
<ui-view name="photos"></ui-view>
</ui-view>
`
})
export class ProfileComponent { }
can I define this state without creating ProfileComponent so state definition becomes something like this:
let states = [
{
name: 'app.profile',
url: '/profile',
template: `
<h4>My profile</h4>
<ui-view>
<ui-view name="about_me"></ui-view>
<ui-view name="photos"></ui-view>
</ui-view>
`
views: {
// <--- removed ProfileComponent was here
'[email protected]': {component: ProfileAboutMeComponent},
'[email protected]': {component: ProfilePhotosComponent},
'help@app': {component: ProfileHelpComponent},
},
},
];
Is it possible to do something like this?
EDITED: This is probably even better:
let states = [
{
name: 'app.profile',
url: '/profile',
views: {
$default: { template: `
<h4>My profile</h4>
<ui-view>
<ui-view name="about_me"></ui-view>
<ui-view name="photos"></ui-view>
</ui-view>
`},
'[email protected]': {component: ProfileAboutMeComponent},
'[email protected]': {component: ProfilePhotosComponent},
'help@app': {component: ProfileHelpComponent},
},
},
];
this way I could replace help@app view as well, because it is static text at bottom of the page.