md-on-select not called when deleting tabs
According to the docs the md-on-select should be called "after the tab has been selected". However, this fails to work when you remove tabs.
This becomes apparent in the dynamic tabs demo on https://material.angularjs.org/#/demo/material.components.tabs
If you have an open chrome console when you switch tabs you can see logs like:
Goodbye Two!
Hello Eight!
Goodbye Eight!
If you select e.g. tab page 3 and delete it there is no such output afterwards even though tab 4 is now selected.
It only works if you open the very last tab and delete it:
Hello Ten!
now click delete
Goodbye Ten!
Hello Nine!
I realize that the log output does not come from md-on-select, but the behavior is the same for me.
Ok, I created a plnkr: http://plnkr.co/edit/DorMcJAmkuFpVG6wTBaj?p=preview
Either open the chrome console or look at the "Last Log:" line at the bottom which is updated by the function defined in the md-on-select declaration.
There, the second issue I experienced also becomes visible: The very first md-on-select event is never fired! This was the case in 0.8.3, though.
If you like I can create a 2nd issue for that.
+1
Not exactly the same, but was having problems with mdTabs after 1) removing some tabs, 2) closing the mdTabs element, 3) reopening the mdTabs element with some newly reattached tabs.
Had to go into mdTabs directive to fix. The scope must be explicitly deleted when mdTabs element is destroyed, or when a new MdTabsController spins up, BOTH the new and old controllers are watching/manipulating the same data, causing any number of defective behaviors.
Here is what was added...
function MdTabs ($mdTheming, $mdUtil, $compile) { return { scope: { noPagination: '=?mdNoPagination', dynamicHeight: '=?mdDynamicHeight', centerTabs: '=?mdCenterTabs', selectedIndex: '=?mdSelected', stretchTabs: '@?mdStretchTabs' }, . . . controller: 'MdTabsController', controllerAs: '$mdTabsCtrl', link: function (scope, element, attr) {
element.on('$destroy', function () {
scope.$destroy();
});
Should be resolved by 5e47b52bd6a8817b2624ca6797b8267a162f84af