html - 单击Angular 9中的按钮后如何显示表单?
问题描述
我的页面上有一个按钮,当我单击它时,我希望我的表单显示在它的正下方。我还想要我点击按钮的次数,它应该显示很多表单。
我是Angular 9的新手,不知道如何在与按钮相同的页面上显示表单。
按钮代码:
<html>
<body ng-app>
<button type="submit" (click)="onClickForm" > Next </button>
</body>
</html>
表格代码:
<html>
<form>
First Name: <input type="text" ng-model="firstname">
</form>
解决方案
解决方案适用于 AngularJS
在视野中
<html>
<body ng-app>
<button type="submit" ng-click="onClickForm()" ng-show="!showForm">
Next
</button>
<form ng-show="showForm">
First Name: <input type="text" ng-model="firstname">
</form>
</body>
</html>
在 js 控制器中
$scope.showForm= false;
$scope.onClickForm = function(){
$scope.showForm = true;
}
推荐阅读
- python - 如何将通过按下按钮获得的值传递给另一个文件python
- arrays - 按日期分隔数据框并计算数学模型 Numpy Python
- annotations - @Resource 是单例还是原型?
- javascript - 用类名折叠第一个找到的 DIV 的 Javascript
- pdf - 在 Liferay 中打开搜索关键字的 Pdf 相关页面
- html - 使用鼠标悬停功能隐藏和显示在同一位置
- arrays - Powershell:将字符串拆分为字符串的*array*
- telegram-bot - Telegram Bot - 底部的可扩展菜单
- wordpress - 在子目录中安装 WordPress 导致的永久链接问题 - 帖子名称问题
- r - 如何使用矩阵中的for循环计算平均绝对误差