client/app/slides/slides_controller.js
author rougeronj
Wed, 08 Apr 2015 00:31:45 +0200
changeset 76 aa0a2d37faca
parent 70 e7e9f2ff6f10
child 99 c7c424e9eed5
permissions -rw-r--r--
show the data of the json received from the server (normalize the exchanged data)

(function(){
	'use strict';

	angular.module('ammicoSlides',['ngResource', 'ngRoute'])
	.controller('slidesCtrl', function($scope, $routeParams, ammicoApi){
		
		$scope.slide = ammicoApi.slide.get({idSlide:$routeParams.idSlide, format:'json'}, function(data){
			data = ammicoApi.sanitizeUrls(data);
		});

	})
	.directive('slideEditor', function() {
		return {
			restrict: 'AE',
			replace: true,
			scope: false,
			templateUrl: 'slides/data_editor.html',
			controller: function($scope){
				$scope.slidesave = function(){
					if(typeof $scope.slide.tags === 'string'){
						$scope.slide.tags = $scope.slide.tags.split(',');
						for (var i = $scope.slide.tags.length - 1; i >= 0; i--) {
							$scope.slide.tags[i] = $scope.slide.tags[i].trim();
						}
					}
					$scope.slide.editMode = false;
					$scope.slide.$save({idSlide:$scope.slide.id, format:'json'});
				};
				$scope.doubleClick = function(){
					$scope.slide.editMode = true;
				};
			}
		};
	});

})();