This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
Docs should be consistent with respect to guidance on use of ng-init #10489
Closed
Description
The ng-init docs state:
The only appropriate use of
ngInit
is for aliasing special properties of
{@link ng.directive:ngRepeatngRepeat
}, as seen in the demo below. Besides this case, you
should use {@link guide/controller controllers} rather thanngInit
to initialize values on a scope.
However, some of the docs' own examples (e.g. ng-mousenter
) explicitly use ng-init
in a way which violates the above guidance.
For example, ng-mouseenter
contains this example:
<example>
<file name="index.html">
<button ng-mouseenter="count = count + 1" ng-init="count=0">
Increment (when mouse enters)
</button>
count: {{count}}
</file>
</example>