我是 Angular 的新手。我正在尝试创建我的第一个简单的 Angular 计算器应用程序,一切都很好。现在我想这样做:当我执行计算时,该计算的结果将显示在另一个视图/页面中。你能告诉我一些方法或关键字吗?
我的应用程序:
代码:
计算器.component.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="card">
<div class="card-header">CALCULATOR</div>
<div class="card-body">
<div class="form-group value">
<div class="form-group row">
<label class="col-md-2 col-form-label">Value 1:</label>
<div class="col-md-10 input-1">
<input [(ngModel)]='number1' class="form-control inp" type="number" name="num1">
</div>
</div>
<div class="form-group row">
<label class="col-md-2 col-form-label">Value 2:</label>
<div class="col-md-10 input-2">
<input [(ngModel)]='number2' class="form-control inp" type="number" name="num2">
</div>
</div>
</div>
<div class="buttons">
<br>
<button class="butt" (click)='sum()'> + </button>
<button class="butt" (click)='diff()'> - </button>
<button class="butt" (click)='mult()'> x </button>
<button class="butt" (click)='divi()'> / </button>
<br><br><br>
</div>
<div class="result">
<h3 class="">Result: {{result}}</h3>
</div>
</div>
</div>
</body>
</html>
白板的微信
qq_遁去的一_1
噜噜哒
相关分类