From the Angular docs regarding ng-init:
This directive can be abused to add unnecessary amounts of logic into your templates. There are only a few appropriate uses of ngInit, such as for aliasing special properties of ngRepeat, as seen in the demo below; and for injecting data via server side scripting.
Could anyone explain the second use case:
...and for injecting data via server side scripting.
Specifically, would it be appropriate to use this directive to pass a value (e.g. model record id) from a Rails/PHP view to an Angular controller?
Other methods (using $location) seem unnecessarily complicated.
'<div class="blah_blah_blah" ng-init="variable=<?php echo $json_data;?>"></div>
– maurycy Dec 15 '15 at 22:07