This is more of a conceptual question. I have the following HTML page:
index.html
<!doctype html>
<html ng-app="myApp">
<head>
<title>Angular Page</title>
<script src="angular.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div ng-controller="myController">
{{ greeting }}
</div>
</body>
</html>
With all files at the root of the directory, I also have the following JS file:
app.js
var app = angular.module('myApp', []);
app.controller('myController', function($scope) {
$scope.greeting = "Hello";
}
When this runs, I of course receive the greeting "Hello" on the HTML page.
However, when I attempt to append an object (for a future ng-repeat element) to the same controller:
var app = angular.module('myApp', []);
app.controller('myController', function($scope) {
$scope.greeting = "Hello";
$scope.users = [
{
"name": "Michael",
"industry": "Music"
},
{
"name": "Michael",
"industry": "Boxing"
},
{
"name": "Michael",
"industry": "Basketball"
}
];
}
The Angular binding is broken, and instead of the greeting "Hello", I receive the {{ name }} expression. (This is with or without the trailing semi-colon on the 'users' object assignment.)
Is there something about my object assignment that caused a break in my Angular code? I wouldn't be exactly sure how to explain what happened.