嗨,當我在Firefox中使用Angular材質打開一個對話框窗口。對話框關閉後,頁面會滾動到頂部。任何人都可以解釋爲什麼發生這種情況或有一個解決方法。Angular 1材質設計在關閉Firefix對話框後滾動到頂部
見https://codepen.io/WitteStier/full/EmzKQb/
HTML
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body ng-app="App" ng-controller="AppCtrl">
<div style="height:1500px;">Scroll down</div>
<md-button ng-click="openDialog($event)">
Open dialog
</md-button>
<div style="visibility: hidden">
<div class="md-dialog-container" id="dialog-window">
<md-dialog>
<md-toolbar>
<div class="md-toolbar-tools">
<h2>Hi</h2>
</div>
</md-toolbar>
<md-dialog-content>
<div class="md-dialog-content">
<p>Creativity is hard to define.</p>
</div>
</md-dialog-content>
</md-dialog>
</div>
</div>
</body>
</html>
JS
angular.module('App', ['ngMaterial'])
.controller('AppCtrl', function($scope, $mdDialog) {
$scope.openDialog = function(ev) {
$mdDialog.show({
contentElement: '#dialog-window',
parent: angular.element(document.body),
targetEvent: ev,
});
};
});
有幾個問題打開有關此https://github.com/angular/material/issues/10897 –