这是我的第一篇文章,因此“Hello World”适合所有人:)。我的angularJS模块有一个新手风格的问题,不能注意到它在哪里。任何人都可以看看我的代码片段,并给我一个建议,为什么显示数据无法正常工作?AngularJS视图控制器
谢谢4帮助!
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js">
var one = angular.module('realSimpleCalc', []);
one.controller('calcContr', function ($scope) {
$scope.score = function() {
if ($scope.condition == '+') {
return ($scope.firstDigit + $scope.secondDigit);
}
else if ($scope.condition == "-") {
return (+$scope.firstDigit - +$scope.secondDigit);
}
else if ($scope.condition == '*') {
return $scope.firstDigit * $scope.secondDigit;
}
else if ($scope.condition == '/') {
return ($scope.firstDigit/$scope.secondDigit);
}
else if ($scope.condition == '%') {
return $scope.firstDigit % $scope.secondDigit;
}
};
});
</script>
<body>
<div ng-app = "realSimpleCalc" ng-controller = "calcContr">
<input type = "number" ng-model = "firstDigit" required/>
<select ng-model = "condition">
<option>+</option>
<option>-</option>
<option>*</option>
<option>/</option>
<option>%</option>
</select>
<input type = "number" ng-model = "secondDigit"/>
<label>=</label>
<input type = "text" ng-bind = "score"/>
</div >
</body>
</html>