【发布时间】:2017-10-27 06:59:20
【问题描述】:
我希望此应用仅在按下提交按钮后显示结果。目前结果显示为表格正在完成。我正在使用 Angular。
HTML:
<html>
<div class="calc-page">
<div ng-app="myApp" ng-controller="myCtrl" class="hello">
<h2 class="text-center">Mark-up vs Gross Profit Calculator</h2>
<form action="action_page.php">
<p>Cost Price: <input type="text" ng-model="costPrice"></p><br>
<p>Sales Price: <input type="text" ng-model="salesPrice"></p><br>
<input value="Submit" class="btn btn-default hide-btn">
<input value="Clear" class="btn btn-default clear-btn">
</form>
<div class="results">
<p>Profit: {{(salesPrice - costPrice)}}</p>
<p>Gross Profit Margin: {{((salesPrice - costPrice) / salesPrice * 100)| number:0}}% </p>
<p>Mark Up: {{((salesPrice - costPrice) / costPrice * 100)| number:0 }}%</p>
</div>
</div>
</html>
JS:
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.costPrice= 0;
$scope.salesPrice= 0;
});
【问题讨论】: