Currently, I am utilizing the md-selected
property within the md-tabs
directive to manage and select tabs. Whenever a new tab is created, my goal is to automatically have it selected. Although this functionality appears to be working in the provided demo, it is accompanied by errors. Are there alternative methods that could be more effective?
JavaScript:
$scope.addTab = function (title, view) {
view = view || title + " Content View";
var newIndex = tabs.push({ title: title, content: view, disabled: false});
$scope.selectedIndex = newIndex;
};
HTML:
<md-tabs md-selected="selectedIndex" md-border-bottom="">
<md-tab ng-repeat="tab in tabs" ng-disabled="tab.disabled" label="{{tab.title}}">
Error Message:
TypeError: Cannot read property 'offsetLeft' of undefined
at updateInkBarStyles (angular-material.js:12808)
at Object.handleSelectedIndexChange [as fn] (angular-material.js:12750)
at Scope.$get.Scope.$digest (angular.js:14308)
at Scope.$get.Scope.$apply (angular.js:14571)
at HTMLFormElement.<anonymous> (angular.js:21571)
at HTMLFormElement.eventHandler (angular.js:3032)