Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

which service converts element and attr names in AngularJS?

Tags:

angularjs

AngularJS converts element and attr names between HTML markup and JS, replacing dashes with camelCasing, i.e. 'myComponent' -> 'my-component' (and back). which AngularJS service or function does this?

thanks -nikita

like image 826
Nikita Avatar asked Nov 20 '13 15:11

Nikita


People also ask

What is Attrs in AngularJS?

Using attrs you are able to access the attributes defined in your html tag like <fm-rating ng-model="$parent.restaurant.price" symbol="$" readonly="true"> So in this case you will have access to the symbol and readonly attributes.

How are attributes marked in AngularJS?

AngularJS directives are extended HTML attributes with the prefix ng- . The ng-app directive initializes an AngularJS application. The ng-init directive initializes application data. The ng-model directive binds the value of HTML controls (input, select, textarea) to application data.

What does $compile do in AngularJS?

Compiles an HTML string or DOM into a template and produces a template function, which can then be used to link scope and the template together.

What is $Index in AngularJS?

The $index variable is used to get the Index of an item repeated using ng-repeat directive in AngularJS.


1 Answers

The actual function that does it is called camelCase() and it is found in jqLite.js which in turn is taken from jQuery.

The use of that function is in the compile stage in directiveNormalize()

update
The reverse is the function snake_case() in angular.js

like image 143
Variant Avatar answered Sep 29 '22 20:09

Variant