In my application I have two tabs, let's simply call them A and B.
Graphs are in tab A. Here's the simple code:
<canvas width="100%" height="30%" style="width: 100%; height: 20%;" id="line_general"
class="chart chart-line" chart-data="myData"
chart-legend="true" chart-colours="colours"
chart-labels="myLabels" chart-series="mySeries"/>
Graph is then populated each time a button is pressed, this button is in the tab A as well:
$scope.buttonPressed = function(){
$http.get('remoteURL').success(function(response, status, headers, config){
myLabels = response.labels;
myData = respose.data;
...
}
Problem comes when user switches to tab B once the graph has been initially populated and, while this tab is active, they resize the browser's window. This action triggers an event on the graph which tries to update but, as it is hidden because of the bootstrap UI's tab mechanism, update does not work and causes an exception.
So my idea would be to listen for tab change event, I can do that by adding a select event to tabs with:
<div ng-controller="MainCtrl" class="wrapper">
<tabset>
<tab ng-repeat="tab in tabs" heading="{{tab.title}}" active="tab.active" disable="tab.disabled" select="tabChanged(tab)">
<div ng-include="tab.content"></div>
</tab>
</tabset>
</div>
and, inside of the handler:
$scope.tabChanged = function(tab){
if(tab.title != "A"){
//disable refresh
}else{
// re-enable refresh
}
};
so, is there a way to accomplish that?