davestacey
7/6/2015 - 2:27 PM

Resume Angular directive & Service

Resume Angular directive & Service

'use strict';

angular.module('core').directive('resume', ['$http', 'Resumebuilder',
	function($http, Resumebuilder) {
		return {
			restrict: 'E',
      templateUrl : 'modules/core/views/resume.html',
			replace: false,
      scope: true,
      controller: function($scope){
        // Read RESUME data
        Resumebuilder.getResume('/data/resume_sheet.json').then(function(retdata){
          $scope.resumeData = retdata.data;
        });
      }
		};
	}
]); 
'use strict';

angular.module('core').factory('Resumebuilder', ['$http', '$cacheFactory',
	function($http, $cacheFactory ) {
		var resume = {};

		return {
			getResume: function(jsonResumePath){
				// var cache = $cacheFactory.get('$http');
				// var resumeCache = cache.get(jsonResumePath);
				// cache.remove(jsonResumePath);

				return $http.get(jsonResumePath, { cache: true } ).
				success(function(response) {
				  resume = response;
				  return resume;
				}).
			  error(function(data, status, headers, config) {
			  	// console.log('Error, config= ', config);
			  });
			}
		};
	}

]);