I am taking an edX course on AngularJS. I have run into a problem with one of the labs, and they don't post solutions, plus their forum seems rather weak, so here I am.
This is the first lab in the course. All the app is supposed to do is display the following:
Module 2 Homework
The Current Date is: “2016-05-26T16:53:22.313Z”
of course, replacing that time with the actual current time. All I get from my program is:
Module 2 Homework
The Current Date is: {{dateAndTime}}
My code is as follows:
<!DOCTYPE html>
<html ng-app="dateTimeApp">
<head>
<title>Date Time App</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7"
crossorigin="anonymous">
</head>
<body ng-controller="firstController">
<div class="container">
<h1>Module 2 Homework</h1>
<h2>The Current Date is: {{dateAndTime}}</h2>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
<script type="text/javascript">
var dateTimeApp = angular.module('dateTimeApp', []);
dateTimeApp.constant('myConfig', {dateTimeReadout: new Date()});
dateTimeApp.controller('firstController', [
'$scope', 'myConfig',
function($scope, myConfig){
$scope.dateAndTime = myConfig.dateTimeReadout;
}
]);
</body>
</html>
I have also tried the following:
dateTimeApp.controller('firstController', [
'$scope',
function($scope){
$scope.dateAndTime = new Date();
I'm a bit lost here. Can someone help? Keep in mind that this is near the beginning of the course, so the answer should be very basic.
By the way, with the h2tag, not sure how to put Angular bit up there between quote marks.