I am new in angularJS, I was practising on angularJS from http://curran.github.io/screencasts/introToAngular/exampleViewer/
In the following example it was say that we are polluting the global space, But I didn't understand how we are polluting the global space in Example 1 but in Example 2 not.
Example 1
<html ng-app>
<head>
<meta charset="utf-8">
<title>Angular.js Example</title>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script>
<script>
function NameCtrl($scope){
$scope.firstName = 'John';
$scope.lastName = 'Smith';
}
</script>
</head>
<body ng-controller="NameCtrl">
First name:<input ng-model="firstName" type="text"/>
<br>
Last name:<input ng-model="lastName" type="text"/>
<br>
Hello {{firstName}} {{lastName}}
</body>
</html>
Example 2
<html ng-app="nameApp">
<head>
<meta charset="utf-8">
<title>Angular.js Example</title>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js"></script>
<script>
var nameApp = angular.module('nameApp', []);
nameApp.controller('NameCtrl', function ($scope){
$scope.firstName = 'John';
$scope.lastName = 'Smith';
});
</script>
</head>
<body ng-controller="NameCtrl">
First name:<input ng-model="firstName" type="text"/>
<br>
Last name:<input ng-model="lastName" type="text"/>
<br>
Hello {{firstName}} {{lastName}}
</body>
</html>
I just want to now How we are polluting the global space in Example 1 with example.