foundation-apps
foundation-apps copied to clipboard
Using `FoundationTabs.activate` throws "$apply already in progress"
My code calls:
FoundationTabs.activate('outputs-tab');
which causes an "$apply already in progress" error. This is due to the scope.$apply()
call in zfTabIndividual
, quoted below.
This seems to be similar to #250 which was resolved by checking if a digest is already in progress before calling $apply.
function zfTabIndividual(foundationApi) {
var directive = {
restrict: 'EA',
transclude: 'true',
link: link
};
return directive;
function link(scope, element, attrs, ctrl, transclude) {
var tab = scope.$eval(attrs.tab);
var id = tab.scope.id;
tab.scope.transcludeFn(tab.scope, function(tabContent) {
element.append(tabContent);
});
foundationApi.subscribe(tab.scope.id, function(msg) {
foundationApi.publish(tab.parentContent, ['activate', tab.scope.id]);
scope.$apply();
});
}
}
I am running into the same issue. It does open the tab though!
If you enclose the publish call in a $timeout, it will not throw the error.
$timeout(function(){ FoundationApi.publish('TAB_ID', 'activate'); });