fix(dialog): Close dialog on location change.

Fix for Issue #335 as demonstrated in http://plnkr.co/MhYssd1GiOx1d1YwOyf0.
Demo of the fix http://plnkr.co/knE57NBIdv0hE53h78Lb