mail.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. app.controller('MailCtrl', ['$scope', function($scope) {
  2. $scope.folds = [
  3. {name: 'Inbox', filter:''},
  4. {name: 'Starred', filter:'starred'},
  5. {name: 'Sent', filter:'sent'},
  6. {name: 'Important', filter:'important'},
  7. {name: 'Draft', filter:'draft'},
  8. {name: 'Trash', filter:'trash'}
  9. ];
  10. $scope.labels = [
  11. {name: 'Angular', filter:'angular', color:'#23b7e5'},
  12. {name: 'Bootstrap', filter:'bootstrap', color:'#7266ba'},
  13. {name: 'Client', filter:'client', color:'#fad733'},
  14. {name: 'Work', filter:'work', color:'#27c24c'}
  15. ];
  16. $scope.addLabel = function(){
  17. $scope.labels.push(
  18. {
  19. name: $scope.newLabel.name,
  20. filter: angular.lowercase($scope.newLabel.name),
  21. color: '#ccc'
  22. }
  23. );
  24. $scope.newLabel.name = '';
  25. }
  26. $scope.labelClass = function(label) {
  27. return {
  28. 'b-l-info': angular.lowercase(label) === 'angular',
  29. 'b-l-primary': angular.lowercase(label) === 'bootstrap',
  30. 'b-l-warning': angular.lowercase(label) === 'client',
  31. 'b-l-success': angular.lowercase(label) === 'work'
  32. };
  33. };
  34. }]);
  35. app.controller('MailListCtrl', ['$scope', 'mails', '$stateParams', function($scope, mails, $stateParams) {
  36. $scope.fold = $stateParams.fold;
  37. mails.all().then(function(mails){
  38. $scope.mails = mails;
  39. });
  40. }]);
  41. app.controller('MailDetailCtrl', ['$scope', 'mails', '$stateParams', function($scope, mails, $stateParams) {
  42. mails.get($stateParams.mailId).then(function(mail){
  43. $scope.mail = mail;
  44. })
  45. }]);
  46. app.controller('MailNewCtrl', ['$scope', function($scope) {
  47. $scope.mail = {
  48. to: '',
  49. subject: '',
  50. content: ''
  51. }
  52. $scope.tolist = [
  53. {name: 'James', email:'james@gmail.com'},
  54. {name: 'Luoris Kiso', email:'luoris.kiso@hotmail.com'},
  55. {name: 'Lucy Yokes', email:'lucy.yokes@gmail.com'}
  56. ];
  57. }]);
  58. angular.module('app').directive('labelColor', function(){
  59. return function(scope, $el, attrs){
  60. $el.css({'color': attrs.color});
  61. }
  62. });