In order to work with the $scope.option
value, I stored it in a temporary variable and then applied operations on the temporary variable after changing all the values of $scope.option
to negative numbers.
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.options=[1,2,3];
var tmp = $scope.options;
for(var i=0;i<tmp.length;i++){
tmp[i] = tmp[i]*-1;
}
console.log($scope.options);
document.getElementById("p1").innerHTML = $scope.options;
});
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<p id="p1"></p>
</div>
</body>
</html>