I want to reload my WordPress AddToAny plugin after http.get response in my Angular file. I read official documentation for this plugin. It says I need to use
a2a.init('page');
to reload it. In Angular I have this code
$http.get('wp-json/wp/v2/get-posts-by-ids?ids=' + "").success(function (res) {
$scope.cars = res;
console.log($scope.cars); // returns Array of objects
$scope.isLoading = false;
$timeout(function(){
console.log( a2a.init('page')); // returns undefined
a2a.init('page');
},3000);
});
In PHP file I’m using AddToAny shortcode to assign result of shortcode to Response that I’m retrieving in Angular
$postsData[] = array(
"title" =>$post->post_title,
"link" => get_permalink($post->ID),
"comment_count" => $post->comment_count,
"thumbnail"=>wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),
'car-thumbnail' ),
"addtoany"=>do_shortcode('[addtoany]'), // returns HTML markup fo AddToAny without any data
"procent" => $procent,
'opinions_rate' => $rate_opinion,
"year" => $year
);
wp_reset_postdata();
return $postsData; // this goes to Angular Response "$scope.cars = res;"
My question is how to make it work with the Ajax, I can’t get rid of AJAX, it has to be.