我的索引上有一个输入名称的表格。使用 ng-submit 提交名称后,我想隐藏表单,然后显示另一个当前未隐藏的 div。我尝试在表单中添加一个按钮以设置 ng-click 并在单击时显示,但无法使其正常工作(我将按钮取出)并且只有提交输入。
HTML
<form name="add-name" id="add-name" ng-submit="mainCtrl.addName()">
<input type="text" class="enter-name" placeholder="Enter your name here..." ng-model="mainCtrl.newName.name">
</form>
<!--- this part should be hidden, but should show when form is submitted --->
<div class="steptwo">
<h4 class="steptwo-text">{{ mainCtrl.newName.name }}</h4>
</div>
控制器
app.controller('mainController', function($scope) {
this.newName = { name: '' };
this.names = this.names || [
{ name: ' ' },
];
this.addName = function() {
this.names.push({
name: this.newName.name
});
this.newName.name = null;
};
return this;
});
任何解释或帮助将不胜感激。