Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hyphen in attribute value causing AngularJs validation break

I just noticed that if i have a hyphen in the form name attribute or the input's name attribute, AngularJS validations don't work.

This doesn't work if i try to validate the fields

<form name="signup-form">
</form>

The below works perfectly

<form name="signupform">
</form>

Can someone please explain why AngularJs doesn't work in the first case? And if we were to have "-" work, how can we do that?

like image 455
hellojava Avatar asked Feb 04 '14 13:02

hellojava


1 Answers

The problem is that the name you put into the name attribute is also the name for the JavaScript property under which the form is published on the scope (e.g. for using it inside your controller). An attribute name containing a hyphen is not valid JavaScript though. I'm pretty sure there is no way around it.

like image 87
muenchdo Avatar answered Sep 22 '22 19:09

muenchdo