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

Mix named views with ui-view #991

Closed
jgoux opened this issue Apr 1, 2014 · 3 comments
Closed

Mix named views with ui-view #991

jgoux opened this issue Apr 1, 2014 · 3 comments

Comments

@jgoux
Copy link

@jgoux jgoux commented Apr 1, 2014

Hi,
I want to mix named views with a "anonymous" ui-view like this :

<!-- index.tpl.html -->
<div data-ui-view></div>
<!-- admin.tpl.html -->
<div data-ui-view="menu"></div>
<div data-ui-view="sidebar"></div>
<div data-ui-view></div><!-- Nested content goes here -->
// app.js
        $stateProvider
            .state('admin', { // Menu + Sidebar + Ui-view for nested content
                abstract: true,
                url: '/admin',
                templateUrl: 'app/admin/admin.tpl.html',
                views: {
                    'menu': {
                        templateUrl: 'app/admin/menu.tpl.html'
                    },
                    'sidebar': {
                        templateUrl: 'app/admin/sidebar.tpl.html'
                    }
                }
            })
            .state('admin.home', { // Nested content
                url: '',
                templateUrl: 'app/admin/home/admin-home-index.tpl.html'
            });

My issue is that all the partials are loaded but they aren't displayed inside my index.tpl.html file.
Is it possible to mix named views with "anonymous" ui-view ?

@nateabele
Copy link
Member

@nateabele nateabele commented Apr 1, 2014

It is possible, but you can't mix top-level view configuration with a views key. Instead, do views: { "": { ... }}.

Per the readme, please direct further support questions to StackOverflow. Thanks.

@nateabele nateabele closed this Apr 1, 2014
@jgoux
Copy link
Author

@jgoux jgoux commented Apr 1, 2014

Thanks for the answer, my working result :

$stateProvider
            .state('admin', {
                abstract: true,
                url: '/admin',
                views: {
                    '': {
                        templateUrl: 'app/admin/admin.tpl.html'
                    },
                    'menu@admin': {
                        templateUrl: 'app/admin/menu.tpl.html'
                    },
                    'sidebar@admin': {
                        templateUrl: 'app/admin/sidebar.tpl.html'
                    }
                }
            })
            .state('admin.home', {
                url: '',
                templateUrl: 'app/admin/home/admin-home-index.tpl.html'
            });
@motin
Copy link

@motin motin commented Aug 31, 2015

Any chance a StackOverflow post was created based on this? I'd upvote that straight away.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.