Can I use a different prefix instead of `ng` with angularjs?

I am new to angularjs. When I read the docs, I found myself using ng as an attribute prefix:

 <body ng:controller="PhoneListCtrl"> <ul> <li ng:repeat="phone in phones"> {{phone.name}} <p>{{phone.snippet}}</p> </li> </ul> </body> 

I want to know if I can change it as another word, for example x ? Since I think x much easier to type than ng .

+21
angularjs
Mar 17 2018-12-12T00:
source share
1 answer

Starting with v1.0.0rc1 , they are all equivalent:

 <div ng-show="isVisible">Using ng-show</div> <div ng:show="isVisible">Using ng:show</div> <div data-ng-show="isVisible">Using data-ng-show</div> <div x-ng-show="isVisible">Using x-ng-show</div> <div class="ng-show:isVisible">Using class="ng-show:isVisible"</div> 

The fiddle works here: http://jsfiddle.net/vojtajina/Fgf3Q/

However, the main reason for this was the resolution of valid HTML. So you can use x-* for your custom directives, but not for corner ones.

Check the docs for more information.

+25
Mar 17 '12 at 20:07
source share



All Articles