client/app/slides/slides_controller.js
author rougeronj
Wed, 27 May 2015 19:02:43 +0200
changeset 99 c7c424e9eed5
parent 76 aa0a2d37faca
permissions -rw-r--r--
refactor the ammicoApi service and put it into a specific module (ammicoCommon). Use factory to serve the resources

(function(){
    'use strict';

    angular.module('ammicoSlides',['ngResource', 'ngRoute'])
    .controller('slidesCtrl', function($scope, $routeParams, Slide, Utils){
        
        $scope.slide = Slide.get({idSlide:$routeParams.idSlide, format:'json'}, function(data){
            data = Utils.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.$update({format:'json'});
                };
                $scope.doubleClick = function(){
                    $scope.slide.editMode = true;
                };
            }
        };
    });

})();