Difference between onLoad and ng-init in angular

ng-init is a directive that can be placed inside div‘s, span‘s, whatever, whereas onload is an attribute specific to the ng-include directive that functions as an ng-init. To see what I mean try something like:

<span onload="a = 1">{{ a }}</span>
<span ng-init="b = 2">{{ b }}</span>

You’ll see that only the second one shows up.

An isolated scope is a scope which does not prototypically inherit from its parent scope. In laymen’s terms if you have a widget that doesn’t need to read and write to the parent scope arbitrarily then you use an isolate scope on the widget so that the widget and widget container can freely use their scopes without overriding each other’s properties.

Leave a Comment