달러 (A $)의 범위를 첨부 기능은 시나리오이 함수 시나리오를 호출AngularJS와 나는이 문제에 달려 내가 왜 그렇게 여기에 설명 할 수
app.controller('MainController', function($scope) {
$scope.rand = randomiseNumber();
function randomiseNumber() {
return Math.random();
}
})
완벽하게 잘 작동이
<div> {{ rand() }} </div>
시나리오 2이 또한 작동하지만 그것은 나에게 각도 오차를 제공
app.controller('MainController', function($scope) {
$scope.rand = function() {
return Math.random();
}
})
오류
I 초기 시나리오에 내 코드를 작성
이 처음이지만 내가 오류가 발생 했으니 까. 그것은 시나리오 1을 사용하여.하지만 시나리오 2가 오류를 출력하는 이유를 알고 싶습니다.
rand() 루프 또는 개별 div –
호출 가능 가능한 각 시간이 다른 값이 의도 된 동작을하는 경우 "오류 : $ rootScope : infdig"를 방지하는 방법 (http://stackoverflow.com/questions/34827249)/how-to-prevent-error-rootscopeinfdig-when-different-value-each-time-is-inte) – georgeawg