Ritu K Ritu K - 6 months ago 8
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

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.

Comments