5

I am creating tabs using AngularStrap and would like to dynamically load an html fragment for each as shown in the following questions, but also would like to specify a dynamic controller.

See: AngularStrap tabs load html fragment

Here are my javascript and html.

function WorkspaceCtrl($scope, $window, $location) {
  // Tab directive
  $scope.tabs = [
    {
        title:'Search',
        page: 'templates/workspace/search.ejs',
        controller: SearchCtrl
    },
    {
        title:'My Searches',
        page: 'templates/workspace/my_searches.ejs',
        controller: MySearchesCtrl
    },
    {
        title:'Community Searches',
        page: 'templates/workspace/community_searches.ejs',
        controller: CommunitySearchesCtrl
    }
  ];
  $scope.tabs.activeTab = 1;
}
<body ng-controller="WorkspaceCtrl">
    <div class="container">
        <section id="tab">
            <div class="bs-docs-example">
            <div ng-model="tabs.activeTab" bs-tabs>
                <div ng-repeat="tab in tabs" data-title="{{ tab.title }}">
                </div>
                <div ng-include src='tabs[tabs.activeTab].page' ng-controller="tabs[tabs.activeTab].controller"></div>
            </div>
            </div>
        </section>
    </div>
</body>

The dynamic pages work fine, but the controllers not only don't work but they also prevent dynamic fragments from being loaded. Do angular strap tabs support this behavior? Thanks in advance.

davidkonrad
  • 83,997
  • 17
  • 205
  • 265
user2437059
  • 63
  • 1
  • 4
  • Just answered my own question. I moved the reference to the controller down into the html fragment and it works great. – user2437059 Sep 10 '13 at 19:49

0 Answers0