我有以下HTML代码:
<body ng-app="MyApp">
<div ng-controller="ctrl" layout="column" layout-fill ng-cloak>
<md-sidenav class="md-sidenav-left" md-component-id="sidenav" md-disable-backdrop md-whiteframe="4">
<md-toolbar class="md-theme-indigo">...</md-toolbar>
<md-list></md-list>
<md-sidenav>
<div layout="column" flex>
<md-content id="content">
<div layout="column" flex>
<md-card id="one" flex>…</md-card>
<md-card id="two" flex>…</md-card>
<!-- … -->
</div>
</md-content>
</div>
</body>
我试图使用这个JS代码,但它不起作用:
$scope.scrollTo = function(item) {
$mdSidenav('sidenav').toggle();
$('#home-content').animate({
scrollTop: $(item).offset().top
}, 'slow');
}
item
参数是mc-card
的ID。我写了上面这段代码question。从scrollTo
内的按钮调用md-list-item
。