Ritu K Ritu K - 1 year ago 44
HTML Question

Variable names seperated with '-' is not recognised by angular application

When I define a model name in two words separated by '-' example: "first-name", it returns me zero instead of the actual value. Here is my code: http://jsbin.com/visabuyuxu/edit?html,js,output
Can someone help me understand this, I am a new bee to angular.

Answer Source

Variable names containing - are not supported in JavaScript as a whole. The parser will interpret it as a subtraction operator.

You need to use either underscores _ or camelCase.