This method can achieve the desired result:
ng-init="$eval(obj.init)"
Check out the PLUNK here
ng-init
essentially performs this action: scope.$eval(attrs.ngInit)
, meaning that the provided expression will be executed in this manner:
scope.$eval('$eval(obj.init)')
This will execute the expression stored in the variable obj.init
.
Simply removing the curly brackets, as some have suggested, will not have the desired effect because it would result in the following function call:
scope.$eval('obj.init')
This would only return the value of obj.init
and not actually execute it!