Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angularjs, using data-ng-controller and ng-controller [duplicate]

Tags:

angularjs

Sometimes I see data-ng-controller but more often ng-controller

The ng-controller I already have used and this seems clear. But data-ng-controller.. what is for?

What are the differences between them, and where to use what?

like image 469
ses Avatar asked Oct 24 '13 13:10

ses


2 Answers

There is no difference except for validation and browser compatibility.

Angular js will not work in IE8 unless data is present

[Update]

  • The above is for versions 1.0.* and 1.2.*
  • 1.3.* does not support ie8 so you don't need data-
like image 122
FreshRob Avatar answered Oct 11 '22 11:10

FreshRob


Angularjs uses a normalization process for directive name / attributes matching.

From the angularjs docu at http://docs.angularjs.org/guide/directive.

Section Matching Directives:

The normalization process is as follows:

Strip x- and data- from the front of the element/attributes. Convert the :, -, or _-delimited name to camelCase.

like image 34
bekite Avatar answered Oct 11 '22 13:10

bekite