Skip to content

Dynamic view names based on the parameters returned while calling the state #2381

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

Closed
modikejal10 opened this issue Nov 19, 2015 · 2 comments
Closed

Comments

@modikejal10
Copy link

I am using Kendo tabstrip with angular ng-repeat and ui-router. Now the tabstrip can have different combination and different number of tabs based on the input. I am able to give different ui-sref and ui-view names to each tab while adding tabs dynamically using angular ng-repeat.

div class="demo-section k-content"
            div kendo-tab-strip="detailsTabStrip" k-ng-delay="Tabs"
              ul
                li 
                ng-repeat="tab in Tabs" ng-class="getClass($first,tab)" ui-sref="{{tab.sref}}"   
                 {{tab.name}}
               /li   
              /ul

               div ng-repeat="tab in Tabs" ui-view="{{tab.view}}"
              /div
            /div
    /div

So, this code gives an individual ui-view to each tab. There can 150 different types of views possible in tabs. So, I cannot hard code the view names in the router file. I need the router to accept a parameter for view name or atleast in some way I can let the router know which view to populate with the html.

$stateProvider
        .state('details.tab', {
            url:'/tab/:tabName',
            views:{

//the view name should be able to either read the stateparam and //accordingly assign template or should atleast be able to read the state and accordingly assign the //template or if views can be a function.

                "details.{{tabName}}":{
                    templateUrl: 'resources/pages/grid.html',
                    controller: 'gridController'
                }
            }
        });

Is it possible to make the views names dynamic in any way. There are other parts in the application which have absolute ui-view defined and work perfectly. The changes made to make views names dynamic for this part should not affect the other parts of application. Can I use relative views to achieve this in any way? Thanks for all the help.

@eddiemonge
Copy link
Contributor

Are all the tabs shown at once? If not, why not have one ui-view that gets populated with the tab content? This also seems like a better question for stackoverflow like this: http://stackoverflow.com/questions/30000462/dynamic-view-names-with-ui-router or maybe take a look at this: #1324

If you do find there is an actual bug, let me know and I will reopen this.

@modikejal10
Copy link
Author

Yepp I made one ui-view for all the tabs and that worked. Thanks for all the help.

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

No branches or pull requests

2 participants