This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tabs): delays disconnect until after the digest is finished
Closes #1048.
- Loading branch information
1 parent
993fa2b
commit 78ba497
Showing
3 changed files
with
13 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
angular.module('material.components.tabs') | ||
.controller('$mdTab', TabItemController); | ||
|
||
function TabItemController($scope, $element, $attrs, $compile, $animate, $mdUtil, $parse) { | ||
function TabItemController($scope, $element, $attrs, $compile, $animate, $mdUtil, $parse, $timeout) { | ||
var self = this; | ||
|
||
// Properties | ||
|
@@ -29,14 +29,18 @@ function TabItemController($scope, $element, $attrs, $compile, $animate, $mdUtil | |
* Add the tab's content to the DOM container area in the tabs, | ||
* @param contentArea the contentArea to add the content of the tab to | ||
*/ | ||
function onAdd(contentArea) { | ||
function onAdd(contentArea, shouldDisconnectScope) { | ||
if (self.content.length) { | ||
self.contentContainer.append(self.content); | ||
self.contentScope = $scope.$parent.$new(); | ||
contentArea.append(self.contentContainer); | ||
|
||
$compile(self.contentContainer)(self.contentScope); | ||
$mdUtil.disconnectScope(self.contentScope); | ||
if (shouldDisconnectScope === true) { | ||
$timeout(function () { | ||
$mdUtil.disconnectScope(self.contentScope); | ||
}, 0, false); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
robertmesserle
Author
Contributor
|
||
} | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This causes a problem for me where the scope is disconnected after it is reconnected by
onSelect
during the initial load. The bug results inng-model
bindings in the initially selected tab not working until the user switches to another tab and switches back.In what case is the
$timeout
necessary? If we need to keep the$timeout
, we should save the promise returned by$timeout
and cancel it inonSelect
where we callreconnectScope
. If that sounds good, I can submit a PR.