var app = angular.module('myApp', []);

app.controller("indexController", function ($scope, specialService) {
	$scope.rice = "Hello World";
	specialService.success(function(data) { 
		$scope.rice = data.rice;
	});
});

app.factory("specialService", function ($http) {
	return $http.get('/api/specialOffer.json');
});

app.directive('rrMap', function() {
	return {
		restrict: 'A',
		template: '',
		link: function(scope, elem, attrs) {
			function init_map() {
				var coords = attrs.rrMap.split(", ");
				var var_location = new google.maps.LatLng(parseFloat(coords[0]), parseFloat(coords[1]));

				var var_mapoptions = {
					center: var_location,
					zoom: 14
				};

				var var_marker = new google.maps.Marker({
				position: var_location,
				map: var_map,
				title:"Map"});

				var var_map = new google.maps.Map(elem[0], var_mapoptions);

				var_marker.setMap(var_map);	

			}
			
			console.log(elem[0].style);
			elem[0].style.minHeight = '400px';
			google.maps.event.addDomListener(window, 'load', init_map);
		}
	}
});