컨트롤러가 두 번 실행되는 문제가 있습니다. 그러나 볼 수있는 복제본이 없습니다 (심지어 내 구성 파일을 통해 대소 문자 검색을 실행해도 경로 구성과 실제 컨트롤러에 하나만 표시됩니다).angularjs 컨트롤러가 2 번 실행합니다.
경로 설정 :
이$routeProvider.when('/cb159e1ec61d0613f10ab397d8bd6782',{
templateUrl: view+'passwordreset.html',
controller:'passwordreset'
});
컨트롤러 :
App.controller('passwordreset',['$scope','$http',
function($scope,$http){
$scope.token='asdf'
console.log($scope.token); // <-- logs 2x to console
}]);
passwordreset.html
: 또한
<div class="row">
<div class="small-12 columns">
<fieldset class="content-box">
password reset {{token}}
</fieldset>
</div>
</div>
, 나는 새로운 경로를 생성 시도했습니다, 여전히 두 번 기록합니다. 캐시도 지 웠습니다.
//route config
$routeProvider.when('/', {
templateUrl: view+'home',
controller:'Home'
});
//template
<div ng-controller="testing">a</div>
//controller
Lmu.controller('Home',function($scope){
$scope.home='home';
alert($scope.home); <-- alerts 2x (two scopes for Home controller are created)
});
아마도 도움이됩니다 ... http : //stackoverflow.com/questions/15535336/combating-angularjs-executing-controller-twice – veritasetratio
나는 내 컨트롤러가 두 번 호출되지 않았는지 확인했습니다. 나는 나의 파일 (1. 컨트롤러 자체, 2. 나의 루트 구성에서)을 통해 검색을 실행할 때 컨트롤러의 두 인스턴스 만 볼 수 있습니다. 다른 컨트롤러에서도 마찬가지입니다. angularjs-batarang 도구를 실행하면 두 개의 개별 범위가 컨트롤러에 대해 생성되었음을 나타냅니다. –
ng-controller를 라우트 구성뿐만 아니라 내 뷰에 추가하면 범위가 4 번 복제됩니다. 예 : Scope00G