Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to use @StateConfig with ui-router multiple view sections #117

Open
pleerock opened this issue Dec 11, 2015 · 7 comments
Open

how to use @StateConfig with ui-router multiple view sections #117

pleerock opened this issue Dec 11, 2015 · 7 comments

Comments

@pleerock
Copy link

Is there such ability? no info about it in the docs and examples

@pleerock pleerock changed the title how to use @StateConfig with ui-router nested views how to use @StateConfig with ui-router multiple view sections Dec 11, 2015
@pleerock
Copy link
Author

@tolemac probably I wrote it wrong. I was talking about multiple root views at the same level with its subviews

@tolemac
Copy link

tolemac commented Dec 11, 2015

I think you have to do nothing new, Have you try this?

@Component({
  selector: 'app',
  template: `
    <div ui-view="view1"></div>
    <div ui-view="view2"></div>
    `
})
@StateConfig([
  { url: '/', views: {
          'view1': {
            templateUrl: 'report-filters.html',
            controller: ComponentView1
          },
          'view2': {
            templateUrl: 'report-table.html',
            controller: ComponentView2
          }
        }
    },
])
export class App {

}

@timkindberg
Copy link
Contributor

Yeah I should add a feature to route a component to a named view. Right now that's not supported I don't think.

@tolemac
Copy link

tolemac commented Dec 12, 2015

I think ng-forward should wait for ngComponentRouter, at the moment I wouldn't loss time with ui-router.

IMHO.

@timkindberg
Copy link
Contributor

Well ui-router has been the leading router. It will support Angular 2 at some point. Right now it's the best we got. We plan to support both it and the new router.

@timkindberg timkindberg added this to the Milestone 3 milestone Dec 15, 2015
@ktersius
Copy link

ktersius commented Jan 5, 2016

So I looked around and I could not find any code samples defining abstract states without a url or component defined.

From what I could see if you try to define such states you get the following error :

Uncaught TypeError: TypeError while analyzing StateConfig 'App' state components.
    Invalid Providers: please make sure all providers are an Injectable(), Component(), Directive(), a Provider, or a module string.
    Here's the invalid values: , 

I suppose I'm doing it wrong somehow. It seems all samples I can find already define top level routes and import the required components for them. How would one do it if you wanted to only define the layout states without knowing what components you will need or the url for them?

@Component({
    selector: 'app',
    template: `<ui-view> </ui-view>`,
    providers : [uiRouter]
})
@StateConfig([
      {
                name  : 'app',
                abstract: true,
                templateUrl: 'default.tmpl'              
      },
    {
        name: 'app.dfl',
        abstract: true,
        views: {
            sidebarLeft: {
                templateUrl: '...'             
            },
            toolbar: {
                templateUrl: '...'              
            },
            content: {
                template: '<div id="admin-panel-content-view" class="{{layout.innerContentClass}}" flex ui-view></div>'
            },
            belowContent: {
                template: '<div ui-view="belowContent"></div>'
            }
        }
    }])
class App {
}

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

No branches or pull requests

4 participants