I am new to angular.
Why my ng-init variable is not overriding in controller?
<div ng-init="name='Emmad'" ng-controller="TodoController as todoCtrl" >
<my-name></my-name>
</div>
my controller is:
App.controller('TodoController',['$scope',function($scope){
$scope.name = "Zahid";
}]);
and my directive is :
App.directive('myName',function(){
return {
restrict: 'EA',
template: '<b>{{name}}<b>'
}
});
The output is always:
Emmad
It should be 'zahid' because I am using the directive in controller and controller will override the name variable.
Questions:
1-Why its not 'zahid'?
2-If I put breakpoint on
$scope.name = "Zahid";
I don't see 'name' variable in $scope why?