You will get a value bindingsinside the context HeroDetailController, whichthis
function HeroDetailController() {
var ctrl = this;
console.log("Here I want to use hero.name: ");
console.log(ctrl.hero);
}
Although the above will not work. Since it will not transfer the initial binding to the component in the 1st digest cycle.
$onInit .
function HeroDetailController() {
var ctrl = this;
console.log("Here I want to use hero.name: ");
ctrl.$onInit = function(){
console.log(ctrl.hero);
}
}
$onInit. $compileProvider config, ( 1.6 +)
.config(function($compileProvider){
$compileProvider.preAssignBindingsEnabled(true)
});
. , .
Demo Plunkr