0

I have multiple tabs on a page for different statuses. Each tab is having its own ui-grid and it is included by ng-include. The sample code is given below.

 <tab heading="@L("Incomplete")">
        <div ng-include="'~/App/common/views/incentives/incomplete.cshtml'"></div>
    </tab>

    <tab heading="@L("PendingApproval")">
        <div ng-include="'~/App/common/views/incentives/pendingApproval.cshtml'"></div>
    </tab>

    <tab heading="@L("AwaitingTracker")">
        <div ng-include="'~/App/common/views/incentives/awaitingtracker.cshtml'"></div>
    </tab>

    <tab heading="@L("DistributedToSales")">
        <div ng-include="'~/App/common/views/incentives/distributed2sales.cshtml'"></div>
    </tab>

I would like to achieve the below functionality.

  • Each tab will load the data when we will focus on it.
  • As now it all the tabs are loading data at a same time but all ui-grids are not loading the data. Only first grid loads the data. refer this video http://screencast.com/t/HM0cfjOgCK

1 Answer 1

0

You can try to reload tabs content on select:

<tab heading="@L("AwaitingTracker")" select="reload()">
        <div ng-include="'~/App/common/views/incentives/awaitingtracker.cshtml'"></div>
    </tab>

<script>

function reload(){
 if($scope.tabs[tabIndex].isLoaded){
      return
    }
    /* or make request for data , delayed to show Loading... vs cache */
    $timeout(function(){
        var jsonFile='data'+(tabIndex +1)+'.json'
        $http.get(jsonFile).then(function(res){
            $scope.tabs[tabIndex].content=res.data;
            $scope.tabs[tabIndex].isLoaded=true;
        });

    }, 2000)
}

</script>

i havent check that this reload() method is working, but i have same problem with slider in tab. With refreshing slider using timeout it shows init values correclty. Check this reload for tabs: tabs with angular: loading tab content on click only with $http

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.