我的索引上有一个表单,它接受名称的输入。在使用ng-submit提交名称后,我想隐藏表单,然后显示另一个当前未隐藏的div。我试着在表单中添加一个按钮来设置ng-click,并在click上显示,但无法让它工作(我把按钮拿出来),只需要提交输入。如何在Angular JS的ng提交后隐藏表格
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;
});
任何解释或帮助将不胜感激。
太棒了,谢谢你的解释。出现steptwo div后无法显示表单输入。我的输出显示在另一个视图中,但无法在相同视图上显示....任何想法?再次感谢! – luke
想通了。再次感谢您的解决方案。 – luke