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

58 lines
1.6 KiB
JavaScript

angular.
module('catalog').
component('anList',{
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) {
$http.get('wp-json/wp/v2/entrevista/?per_page=100').then(function(res) {
$scope.entrevistas = res.data;
console.log(res);
});
}
});
angular.
module('catalog').
component('anHome',{
templateUrl: localized.partials + 'home.template.html',
controller: function($scope, $rootScope, $http, $routeParams) {
console.log($rootScope.loading);
$scope.loading = true;
window.scrollTo(0,0);
$http.get('wp-json/wp/v2/slideshow').then(function(res) {
$scope.slides = res.data;
$scope.loading = false;
});
}
});
angular.
module('catalog').
component('anContact',{
templateUrl: localized.partials + 'contact.template.html'
});
angular.
module('catalog').
component('anInfo',{
templateUrl: localized.partials + 'info.template.html'
});
angular
.module('catalog')
.component('anContent',{
templateUrl: localized.partials + 'content.template.html',
controller: function($scope, $http, $routeParams, $sce,$rootScope) {
$rootScope.startLoading();
console.log($routeParams.slug);
window.scrollTo(0,0);
$http.get('wp-json/wp/v2/pages/?slug='+$routeParams.slug).then(function(res) {
$scope.post = res.data[0];
$scope.content = $sce.trustAsHtml($scope.post.content.rendered);
$rootScope.stopLoading();
});
}
});