2016-07-13 5 views
0

I의 값을 계산하고, 예 .FOR 변수 값 (9)에 의해 전체를 분할 오전 :수학 오류

$scope.wald_costs = Math.round($scope.logistics_costs + $scope.refurbishment_costs + $scope.insurance_costs + $scope.priceful + $scope.t/$scope.$scope.sharable_with) 

$scope.wald_costs = Math.round(1000 + 500 + 4500 + 45000 + 27000/9) 

$scope.wald_costs = 8666 가되도록 가정 될 것이다하지만 <b>{{wald_costs}}</b>을 인쇄 할 때 적절한 출력을 얻지 못하고 있습니다. 대신 내가 출력에서 ​​얻을 것은 내가이 문제를 해결 할 수있는 방법이 6000450003375

$scope.t = 27000 
$scope.logistics_costs = 1000 
$scope.refurbishment_costs = 500 
$scope.insurance_costs = 4500 
$scope.priceful = 45000 
$scope.sharable_with = 9 

$scope.wald_costs = Math.round(($scope.logistics_costs + $scope.refurbishment_costs + $scope.insurance_costs + $scope.priceful + $scope.t/$scope.$scope.sharable_with)) 

처럼? 이 8666`은 다음 몇 가지 괄호를 추가 할 필요가`해야하는데 경우

+2

을보십시오. – Yoshi

+0

오타가 있거나'$ scope.t' 만'$ scope.sharable_with'로 나눕니 까? – rpadovani

답변

0

사용

$scope.wald_costs = Math.round(($scope.logistics_costs + $scope.refurbishment_costs + $scope.insurance_costs + $scope.priceful + $scope.t)/$scope.$scope.sharable_with) 
1

하면이 http://plnkr.co/edit/8ZZY2XtxB2EbB64hWYyn?p=preview

$scope.t = 27000; 
$scope.logistics_costs = 1000; 
$scope.refurbishment_costs = 500; 
$scope.insurance_costs = 4500; 
$scope.priceful = 45000; 
$scope.sharable_with = 9; 
$scope.wald_costs = Math.round(($scope.logistics_costs + $scope.refurbishment_costs + $scope.insurance_costs + $scope.priceful + $scope.t)/$scope.sharable_with); 
    alert($scope.wald_costs); 
+0

나는 그것을 시험해 보았다. 그러나 그것을 추가하는 대신 모든 숫자를 연결했다. –

+0

예상되는 결과는 무엇입니까? plnkr 링크를 참조하십시오. –

+0

고마워. 나는 그것을 해결했다. 범위 변수 중 하나가 숫자 대신 텍스트를 사용하여 문제를 일으키는 이유는 무엇입니까? –