-
-
Save codecademydev/19f253cdb592e30c5568 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = angular.module('CalendarApp', ['ngRoute']); | |
app.config(function($routeProvider) { | |
$routeProvider | |
.when('/', { | |
controller: 'DayController', | |
templateUrl: 'views/day.html' | |
}) | |
.when('/:id', { | |
controller: 'EventController', | |
templateUrl: 'views/event.html' | |
}) | |
.otherwise({ | |
redirectTo: '/' | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Format a date so it displays in the format "Friday 1/16" --> | |
<h2 class="date">{{ day.date | date: 'EEEE M/dd' }}</h2> | |
TODO: Loop through events and display each one with this HTML | |
<div class="event" ng-repeat="event in day.events"> | |
<a href="#/{{$index}}"> | |
<h3 class="name"> {{ event.name }} </h3> | |
<p><span class="from"> {{ event.from | date: "h:mma"}} </span> - <span class="to"> {{ event.to | date: "h:mma" }} </span></p> | |
</a> | |
</div> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="event-detail"> | |
<h2 class="event-name"> {{ event.name }} </h2> | |
<p class="time"> <span class="from"> {{ event.to | date: "h:mma" }} </span> - <span class="to"> {{ event.to | date: "h:mma" }} </span></p> | |
<p class="where"> {{ event.where }} </p> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.controller('EventController', ['$scope', '$routeParams', 'events', function($scope, $routeParams, events) { | |
events.success(function(data) { | |
$scope.event = data.events[$routeParams.id]; | |
}); | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory('events', ['$http', function($http) { | |
return $http.get('https://s3.amazonaws.com/codecademy-content/courses/ltp4/events-api/events.json') | |
.success(function(data) { | |
return data; | |
}) | |
.error(function(err) { | |
return err; | |
}); | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<link href="https://s3.amazonaws.com/codecademy-content/projects/bootstrap.min.css" rel="stylesheet" /> | |
<link href="css/main.css" rel="stylesheet" /> | |
<script src="js/vendor/angular.min.js"></script> | |
</head> | |
<body ng-app="CalendarApp"> | |
<div class="header"> | |
<div class="container"> | |
<img src= "img/logo.svg" width="51" height="54"> | |
</div> | |
</div> | |
<div class="main"> | |
<div class="container"> | |
<div ng-view></div> | |
</div> | |
</div> | |
<!-- Modules --> | |
<script src="js/app.js"></script> | |
<!-- Controllers --> | |
<script src="js/controllers/DayController.js"></script> | |
<script src="js/controllers/EventController.js"></script> | |
<!-- Services --> | |
<script src="js/services/events.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment