I am told that every AngularJS page with the ngApp directive has a controller, providing for $scope. In the earliest, simplest example given by the W3Schools site the code has no ngController tag:
<!DOCTYPE html>
<html lang="en-US">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<body>
<div ng-app="">
<p>Name : <input type="text" ng-model="name"></p>
<h1>Hello {{name}}</h1>
</div>
</body>
</html>
The page obviously works -- try it on the W3Schools link -- and has scope ($scope.name). Is there always an implicit controller?
Thanks, Jerome.
There is no controller on this page. But ng-controller
isn't the only directives that create a $scope. ng-app
also creates a $scope and that is the $scope that name
is on
A controller is just some code that interacts with a scope.