Initially I was thinking $scope is automatically injected to controller in Angular JS.But Now I am confused. I wrote a small snippet of code.
index.html
<html ng-app>
<body ng-controller="Controller">
<input type="text" ng-model="fname">
<span ng-bind="fname"></span>
<body>
</html>
script.js
angular.module('docsSimpleDirective', [])
.controller('Controller', ['$http', function($scope) {
$scope.fname = 'Foo Bar';
}])
As you can see I am not injecting $scope here to the controller. When the page loads, it does not show 'Foo Bar' on the textfield or span. But when I start writing some value on the text field , It reflects on the span. This means 'fname' declared in scope.But why its not showing on the page load. Everything works fine when I inject $scope.
$httpinto the controller, but calling it$scope.