|
| 1 | +var aMailServices = angular.module('AMail', []); |
| 2 | + |
| 3 | +function emailRouteConfig($routeProvider) { |
| 4 | + $routeProvider. |
| 5 | + when('/', { |
| 6 | + controller: ListController, |
| 7 | + templateUrl: 'list.html' |
| 8 | + }). |
| 9 | + when('/view/:id', { |
| 10 | + controller: DetailController, |
| 11 | + templateUrl: 'detail.html' |
| 12 | + }). |
| 13 | + otherwise({ |
| 14 | + redirectTo: '/' |
| 15 | + }); |
| 16 | +} |
| 17 | + |
| 18 | +aMailServices.config(emailRouteConfig); |
| 19 | + |
| 20 | +messages = [{ |
| 21 | + id: 0, |
| 22 | + |
| 23 | + subject: 'Hi there, old friend', |
| 24 | + date: 'Dec 7, 2013 12:32:00', |
| 25 | + recipients: ['[email protected]'], |
| 26 | + message: 'Hey, we should get together for lunch sometime and catch up. There are many things we should collaborate on this year.' |
| 27 | +}, { |
| 28 | + id: 1, |
| 29 | + |
| 30 | + subject: 'Where did you leave my laptop?', |
| 31 | + date: 'Dec 7, 2013 8:15:12', |
| 32 | + recipients: ['[email protected]'], |
| 33 | + message: 'I thought you were going to put it in my desk drawer. But it does not seem to be there.' |
| 34 | +}, { |
| 35 | + id: 2, |
| 36 | + |
| 37 | + subject: 'Lost python', |
| 38 | + date: 'Dec 6, 2013 20:35:02', |
| 39 | + recipients: ['[email protected]'], |
| 40 | + message: "Nobody panic, but my pet python is missing from her cage. She doesn't move too fast, so just call me if you see her." |
| 41 | +}, ]; |
| 42 | + |
| 43 | +function ListController($scope) { |
| 44 | + $scope.messages = messages; |
| 45 | +} |
| 46 | + |
| 47 | +function DetailController($scope, $routeParams) { |
| 48 | + $scope.message = messages[$routeParams.id]; |
| 49 | +} |
0 commit comments