Skip to content
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.

Simplified state definition #34

Open
zmitic opened this issue Jun 6, 2017 · 0 comments
Open

Simplified state definition #34

zmitic opened this issue Jun 6, 2017 · 0 comments

Comments

@zmitic
Copy link

zmitic commented Jun 6, 2017

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant