/**
* @ngdoc legenda
* @name InicioCtrl
* @module s4c.components.legenda.InicioCtrl
*
* @description Controller do módulo de Legenda
*
*
*/
(function () {
'use strict';
LegendaCtrl.$inject = ['$scope', '$stateParams', 'LegendaService', '$sce', 'CamadasService', '$window', '$rootScope'];
angular.module('s4c.controllers.LegendaCtrl', ['s4c.services.LegendaService']).controller('LegendaCtrl', LegendaCtrl);
/**
* @method LegendaCtrl
*
* @param {*} $scope
* @param {*} $stateParams
* @param {*} LegendaService
* @param {*} $sce
* @param {*} CamadasService
* @param {*} $window
* @param {*} $rootScope
*/
function LegendaCtrl($scope, $stateParams, LegendaService, $sce, CamadasService, $window, $rootScope) {
var numero = parseInt($stateParams.id, 10);
LegendaService.pegarLegenda(numero)
.then(function (data) {
$scope.data = data;
});
$scope.representacoes = [];
if ($window.parent != null) {
var parentScope = $window.opener.ScopeToShare;
console.log("parentScope: " + parentScope);
$scope.representacoes = parentScope.representacoes;
}
var representacaoLegenda = _.find($scope.representacoes, function (rep) {
return rep.id == numero;
});
if (representacaoLegenda != null && representacaoLegenda.categorias != null && representacaoLegenda.categorias.length > 0) {
$scope.categorias = representacaoLegenda.categorias;
}
$scope.res = $scope.$root.res;
$scope.trustAsResourceUrl = $sce.trustAsResourceUrl;
if ($stateParams.token) {
sessionStorage.s4cToken = $stateParams.token;
}
}
}());