要素へのスクロールに $anchorScroll を使用すると問題が発生します。
これは私のソースです:
親コントローラー:
var myApp = angular.module('myApp');
myApp.controller('ParentCtrl',function($scope){
}
チルドレンコントローラー:
var myApp = angular.module('myApp');
myApp.controller('ChildrenCtrl',function($scope,$location,$anchorScroll){
$location.hash('tries');
$anchorScroll();
console.log('Hihi');
}
索引.html
<div ng-controller="ParentCtrl">
<div ng-view> </div>
</div>
私が受け取った結果:
HiHi
HiHi
わかりません、なぜchildrentコントローラーが2回呼び出されるのですか?
お願い助けて!
ありがとう!