I really thought I'm getting the hang of AngularJs slowly - but seems I'm still totally green.....
I tried to put together a tiny demo to show the ng-repeat directive, and now nothing works - I'm just getting a blank screen, and I have no clue as to why....
Can anyone enlighten me??
This is my HTML file:
<!doctype html>
<head>
<!-- include link to Angular -->
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
<!-- include app.js -->
<script src="app.js"></script>
</head>
<body ng-app="myapp">
<div ng-controller="mycontroller as vm">
<label>My company:</label>
<hr>
<div id="divTeam" ng-repeat="m in vm.team">
<p>
{{m.firstname}} {{m.name}} ({{m.tag}})
</p>
</div>
</div>
</body>
and this is my app.js file (same directory):
var app = angular.module('myapp', []);
app.controller('mycontroller', function ($scope) {
$scope.team = [
{ name: "Brown", firstname: "Leo", tag: "lebr" },
{ name: "Smith", firstname: "Adrian", tag: "adsm" },
{ name: "Loflin", firstname: "Wes", tag: "welo" },
{ name: "Hackett", firstname: "John", tag: "joha" }
]
}
);
I don't get it....
- I'm creating the Angular module called
myapp I reference that module in the
<body ng-app="myapp">tagI'm creating an Angular controller called
mycontrollerI reference that in the
<div ng-controller="mycontroller as vm">tagI'm creating an array of objects on the
$scope- I was expecting to be able to iterate over this array of objects using the
ng-repeat="m in vm.team"directive
but all I get right now is an empty screen with just the title "My company:" - and nothing else.....
- I checked the URL to the Angular JS file - it's correct as far as I can tell.
- I checked the Javascript console in IE or Chrome - no errors or info messages to be seen anywhere.....
- If I add just a plain little expression like
{{1+2}}to my HTML, it does get evaluted to "3", so I'm pretty sure Angular is up and running....
So what am I missing? (I'm a long-time .NET developer, always struggling with all things Javascript.....)