私は非常に単純なscrollToを角度1.xで使用しようとしています。私はnaviagationメニューリンクをクリックするとdiv#idにスクロールする必要があります。私はこれを「約束」で動かすことしかできない。角度アンカースクロール無し
例えば、この作品:
<li><a href="#" ng-click="tracking()">Go to Tracking</a></li>
$scope.tracking = function() { // go to tracking when header button is clicked
$http.get('/includes/modules/get_home_destinations.php')
.then(function(reply){
if (reply.data) {
$scope.destinations = reply.data;
$location.hash('home-tracking');
}
});
};
しかし、これは応答しません:
$scope.tracking = function() { // go to tracking when header button is clicked
$location.hash('home-tracking');
};
それは約束が必要とされているかのようだが、これはなくて、単純なクリックで動作させるために約束?コントローラファイル内のHTMLファイル内
<div id="home-tracking">
<h1>Home Traking Content</h1>
</div>
<a ng-click="tracking()">Go to Tracking</a>
angular.module('trackingApp').controller('TrackingCtrl', function($location, $anchorScroll) {
$scope.tracking = function() {
$location.hash('home-tracking');
$anchorScroll();
}
})
'href ="# "'なしで試すことができますか? –
@MuhammedHasanCelikそれは働いた!なぜhrefは問題を引き起こしますか? –