Skip to content
This repository has been archived by the owner on Nov 30, 2018. It is now read-only.

map render problem in different tabs #1395

Closed
uguryilmaz opened this issue Jul 21, 2015 · 6 comments
Closed

map render problem in different tabs #1395

uguryilmaz opened this issue Jul 21, 2015 · 6 comments
Labels

Comments

@uguryilmaz
Copy link

i have a tab control in my form. every tab page has its map object. first tab loads succesfully but maps in other tabs not loaded successfuly. here is plunker:

http://plnkr.co/edit/JUHRt5ogLcq0Eq6uo8n1?p=preview

@rummelsworth
Copy link
Contributor

The behavior is caused by the maps in unselected tabs being rendered into hidden elements. The correct approach is to prevent map creation until the elements that will show it aren't hidden. You can use tab's active attribute along with ng-if to help with this...

However, this is really strange because the FAQ's recommendation to use ng-if doesn't seem to help. See updated plunker here: http://plnkr.co/edit/pmCPVhGeIPQnUFqmCcJF?p=preview

Not sure what the problem is. Hopefully I'm missing something obvious. @cthrax thoughts?

@cthrax
Copy link
Contributor

cthrax commented Jul 21, 2015

The ng-if condition is changing in the same digest loop as the display of the tabs, so the DOM still hasn't had a chance to render. If you disconnect those conditions, which honestly feels a little weird semantically, it will render properly. See this plnkr for an example http://plnkr.co/edit/KatCddVOfefPw9c09yPM?p=preview

@rummelsworth
Copy link
Contributor

Nice 👍 I've learned another nuance of Angular's digestion...

@uguryilmaz Follow up and reopen if this doesn't resolve the issue for you. Thanks.

@uguryilmaz
Copy link
Author

thanks so much @cthrax and @wrummler . that solves my problem.

@nmccready
Copy link
Contributor

🎱

@SunPj
Copy link

SunPj commented Aug 13, 2016

Sometimes just setting ng-if to true doesn't solve the problem. I use following code to refresh map.

$scope.showMap = false;
$timeout(function() {
    $scope.showMap = true;
});

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants