{"size": 1723, "ext": "js", "max_stars_repo_path": "client/src/app/agencies/list/directive.js", "max_stars_repo_name": "mopiou/sdw-immo-front-back-office", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "client/src/app/agencies/list/directive.js", "max_issues_repo_name": "mopiou/sdw-immo-front-back-office", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "client/src/app/agencies/list/directive.js", "max_forks_repo_name": "mopiou/sdw-immo-front-back-office", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 34.46, "max_line_length": 90, "alphanum_fraction": 0.4585026117}
(function() {
    'use strict';

    function listAgenciesDirective() {
        return {
            restrict: 'EA',
            replace: true,
            templateUrl: './src/app/agencies/list/template.html',
            scope: {},
            controllerAs: 'vm',
            bindToController: true,
            /* jshint unused:false*/
            controller: function($log,$state, ListAgenciesService,DeleteAgenciesService) {
                var vm=this;
                ListAgenciesService.getAgencies()
                    .then(function(agencies) {
                        //$log.debug('agencies in directives :',agencies.data);
                        vm.agencies = agencies.data;

                    }, function(error){
                        $log.error('Error agencies', error);
                    });


                vm.deleteAgencie = function(id){
                    $log.debug('delete : ');
                    $log.debug(id);

                    DeleteAgenciesService.deleteAgencie(id)
                    .then(function(agencie) {
                        $log.debug('agencies in directives :',agencie.data);
                        //vm.agencies = agencies.data;
                        $state.reload('root.agencies');
                        //alert('L\'agence ('+agencie.data.name+') a été supprimé');

                    }, function(error){
                        $log.error('Error agencies', error);
                    });
                };
                
            },
            link: function(scope, elm, attrs){
            }
        };
    }

angular.module('app.directives.agencies.list', ['app.services.agencies.list'])
    .directive('listAgencies', listAgenciesDirective); 

})();