anorgatarrak-wordpress-theme/app/catalog/catalog.component.js

97 lines
2.9 KiB
JavaScript
Raw Permalink Normal View History

angular.
module('catalog').
component('anList',{
2017-11-09 19:40:49 +01:00
templateUrl : localized.partials + 'catalog.template.html',
//'<a ng-repeat="item in $ctrl.catalog" class="square" style="background-image:url(\'{{item.img}}\');" ng-href="#!/catalog/{{item.id}}"></a>',
controller :
function($scope, $http, $routeParams, $rootScope) {
$rootScope.lanEs = "http://es.anorgatarrak.eus/catalog/";
$rootScope.lanEu = "http://anorgatarrak.eus/catalog2/";
2018-02-15 19:26:12 +01:00
$http.get('wp-json/wp/v2/entrevista/?per_page=100').then(function(res) {
$scope.entrevistas = res.data;
console.log(res);
2017-11-09 19:40:49 +01:00
});
}
});
angular.
module('catalog').
component('anHome',{
2017-11-09 19:40:49 +01:00
templateUrl: localized.partials + 'home.template.html',
controller: function($scope, $rootScope, $http, $routeParams) {
$rootScope.lanEs = "http://es.anorgatarrak.eus";
$rootScope.lanEu = "http://anorgatarrak.eus";
console.log($rootScope.loading);
$scope.loading = true;
window.scrollTo(0,0);
2017-11-09 19:40:49 +01:00
$http.get('wp-json/wp/v2/slideshow').then(function(res) {
$scope.slides = res.data;
$scope.loading = false;
2017-11-09 19:40:49 +01:00
});
}
});
angular.
module('catalog').
component('anContact',{
2017-11-09 19:40:49 +01:00
templateUrl: localized.partials + 'contact.template.html'
});
angular.
module('catalog').
component('anInfo',{
templateUrl: localized.partials + 'info.template.html',
controller: function($rootScope) {
}
2017-11-09 19:40:49 +01:00
});
angular.
module('catalog').
component('anLanguage', {
templateUrl: localized.partials + 'language.template.html',
controller: function($scope,$http,$routeParams,$sce,$rootScope,$location) {
console.log($rootScope);
$scope.lan = function (l) {
if (l=='es') {
window.location.assign($rootScope.lanEs);
} else {
window.location.assign($rootScope.lanEu);
}
};
//console.log("anLanguage:"+$routeParams);
//$http.get('wp-json/anorgatarrak/v1/link/'+$routeParams.slug).then(function(res) {
// data = res.data;
// console.log(data);
//jQuery('#lan_link_eus').attr('href',data[1][1]);
//jQuery('#lan_link_es').attr('href',data[0][1]);
//});
}
});
2017-11-09 19:40:49 +01:00
angular
.module('catalog')
.component('anContent',{
templateUrl: localized.partials + 'content.template.html',
2018-02-15 19:26:12 +01:00
controller: function($scope, $http, $routeParams, $sce,$rootScope) {
$rootScope.startLoading();
2017-11-09 19:40:49 +01:00
console.log($routeParams.slug);
window.scrollTo(0,0);
2018-02-15 19:26:12 +01:00
$http.get('wp-json/wp/v2/pages/?slug='+$routeParams.slug).then(function(res) {
$scope.post = res.data[0];
console.log($scope.post.link_es);
2018-02-15 19:26:12 +01:00
$scope.content = $sce.trustAsHtml($scope.post.content.rendered);
//console.log('llamamos el cambi ode idioma');
$rootScope.lanEs = $scope.post.link_es;
$rootScope.lanEu = $scope.post.link_eu;
//jQuery('#lan_link_eus').attr('href',"/"+$scope.post.link_eu); //.on('click',function() { alert('sss'); });
//jQuery('#lan_link_es').attr('href',"/"+$scope.post.link_es);
2018-02-15 19:26:12 +01:00
$rootScope.stopLoading();
});
2017-11-09 19:40:49 +01:00
}
});