1

I'm using this library https://github.com/tchatel/angular-treeRepeat

So to create a list of nodes this syntax is used :

<li frang-tree-repeat="node in treeData>

frang-tree-repeat is a custom tag and so it has to be configured somewhere within the library ?

Searching the src of https://github.com/tchatel/angular-treeRepeat I do not see any references to frang-tree-repeat so how is this tag configured or in other words how is frang-tree-repeat interpreted ?

Yogeshree Koyani
  • 1,649
  • 10
  • 19
blue-sky
  • 51,962
  • 152
  • 427
  • 752
  • 1
    It's here https://github.com/tchatel/angular-treeRepeat/blob/master/app/js/directives.js#L18 Remember to normalize directive names: frangTreeRepeat. – dfsq Oct 07 '15 at 10:54
  • @dfsq so directive frangTreeRepeat is read as frang-Tree-Repeat on angular view page? Is this insertion of '-' to read a directive from view page an angularjs standard ? – blue-sky Oct 07 '15 at 11:06
  • Read my answer, I explained it why this normalization is necessary. – dfsq Oct 07 '15 at 12:34

2 Answers2

1

Angular normalizes directive (both attribute and tag) names from kebab-case to camelCase. This is necessary since names of HTML tags and attributes are better written in kebab-case (because names are not case sensitive in HTML) while in Javascript kebab-case names would not be valid identifiers and could not be used for directives names (well, they could, but it would require additional wrapping into quotes).

That's the reason why you have to preform normalization from HTML notation to JS. Angular has $normalize service which is used for this. So it means, that if in HTML you have frang-tree-repeat it will be translated to frangTreeRepeat in Javascript.

In your case, your directive is found here: https://github.com/tchatel/angular-treeRepeat/blob/master/app/js/directives.js#L18

dfsq
  • 191,768
  • 25
  • 236
  • 258
0

frang-tree-repeat is a custom directive which is defined in a module app.directives in angular-treeRepeat. As @dfsq pointed out, its implementation can be found here.

Note that it requires frangtreein its definition require: ^frangTree:

When a directive uses this option, $compile will throw an error unless the specified controller is found. The ^ prefix means that this directive searches for the controller on its parents (without the ^ prefix, the directive would look for the controller on just its own element).

DonJuwe
  • 4,477
  • 3
  • 34
  • 59