/**
* @ngdoc directives
* @name EscolhaZona
* @module s4c.directives.twitterarea.EscolhaZona
*
* @description
* `EscolhaZona` Controller do módulo de EscolhaZona
*
*
*/
'use strict';
angular.module('s4c.directives.escolhaZona', [
'ngMaterial',
])
.directive('escolhaZona', escolhaZona)
.filter('propsFilter', function () {
return function (items, props) {
var out = [];
if (angular.isArray(items)) {
items.forEach(function (item) {
var itemMatches = false;
var keys = Object.keys(props);
for (var i = 0; i < keys.length; i++) {
var prop = keys[i];
var text = props[prop].toLowerCase();
if (item[prop].toString().toLowerCase().indexOf(text) !== -1) {
itemMatches = true;
break;
}
}
if (itemMatches) {
out.push(item);
}
});
} else {
// Let the output be the input untouched
out = items;
}
return out;
}
});
escolhaZona.$inject = ['API_ENDPOINT', '$http', 'ZonaObservacaoService'];
function escolhaZona(API_ENDPOINT, $http, ZonaObservacaoService) {
return {
restrict: 'EA',
templateUrl: 'app/directives/twitter-area/escolha-zona.html',
replace: true,
scope: {},
controller: function ($scope, $rootScope, $sce) {
ZonaObservacaoService.pegarZonas()
.then(function (zonas) {
$scope.zonas = zonas;
console.log(zonas);
});
},
link: function ($scope, $elem, $attrs) { }
};
}