I have the following HTML code:
<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>
I have tried to use this JS code but it doesn't work:
$scope.scrollTo = function(item) {
$mdSidenav('sidenav').toggle();
$('#home-content').animate({
scrollTop: $(item).offset().top
}, 'slow');
}
The item
parameter is mc-card
's id. I write the above code reading this question. scrollTo
is called from buttons inside md-list-item
.