/EmailController.js Secret
Created
March 22, 2017 20:28
Star
You must be signed in to star a gist
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('OutboxApp', ['ngRoute']); | |
app.config(function($routeProvider){ | |
$routeProvider | |
.when('/outbox', { | |
controller: "HomeController", | |
templateUrl: "view/home.html" | |
}) | |
.when('/outbox/:id', { | |
controller: "EmailController", | |
templateUrl: "view/email.html" | |
}) | |
.otherwise({ | |
redirectTo:'/outbox' | |
}); | |
}); |
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
<a class="back" href="#/outbox">Back</a> | |
<div class="email-view"> | |
<h2 class="subject"> {{email.subject}} </h2> | |
<span class="from"> {{email.from}} </span><span class="date"> </span> | |
<p class="message"> {{email.message}} </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('EmailController', ['$scope', 'emails', '$routeParams', function($scope, emails, $routeParams) { | |
emails.success(function(data) { | |
$scope.email = data[$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('emails', ['$http', function($http) { | |
return $http.get('https://s3.amazonaws.com/codecademy-content/courses/ltp4/emails-api/emails.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
<div class="main"> | |
<div class="container"> | |
<div class="email" ng-repeat="email in emails"> | |
<a href="#/outbox/{{$index}}"> | |
<span class="from">{{ email.from }}</span> | |
<span class="subject">{{ email.subject }}</span> | |
<span class="date">{{ email.datetime | date }}</span> | |
</a> | |
</div> | |
</div> | |
</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('HomeController', ['$scope', 'emails', function($scope, emails) { | |
emails.success(function(data) { | |
$scope.emails = data; | |
}); | |
}]); |
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> | |
<script src="https://code.angularjs.org/1.2.28/angular-route.min.js"></script> | |
</head> | |
<body ng-app="OutboxApp"> | |
<div class="header"> | |
<div class="container"> | |
<img src="img/logo.svg" width="140" height="150"> | |
</div> | |
</div> | |
<div ng-view></div> | |
<!-- Modules --> | |
<script src="js/app.js"></script> | |
<!-- Controllers --> | |
<script src="js/controllers/HomeController.js"></script> | |
<script src="js/controllers/EmailController.js"></script> | |
<!-- Services --> | |
<script src="js/services/emails.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment