0
我曾经广泛使用Jquery。现在我偶然发现了Angularjs,我正在试着理解它是如何工作的,而且我对它的AutoMagic方式非常兴奋。例如,我可以通过使用ng-click
,ng-hide
& ng-show
来完成隐藏和显示几个块的下面的过程。如何在js代码的点击事件上显示/隐藏元素?
<form id="signup-form" ng-submit="processForm()" ng-hide="showConfirm" >
<input type="text" name="user" ng-model="name">
<button type="submit" id="submit" ng-click="showConfirm = ! showConfirm">Submit</button>
</form>
<div class="col-md-12 confirmation" ng-show="showConfirm">
<h2 >Thanks alot for your feedback.</h1>
</div>
但是,我仍然想知道我怎么能从代码,从控制器说。 jQuery中做的一个方法是这样的:
$("#submit").click(function() {
$(".confirmation").show();
$("#signup-form").hide();
});
也许,如果我想验证的形式,我可以在jQuery中使用.preventDefault();
,做一些事情。这些在AngularJs中如何工作?
请参阅:[我如何在AngularJS中思考如果我有jQuery背景?](http://stackoverflow.com/q/14994391/1313143)。 – MarioDS 2014-10-02 17:50:29
https://docs.angularjs.org/guide/forms有关于验证的信息.. – smerny 2014-10-02 17:51:21