If you are using views and routing in AngularJS, each routed page must have a controller. This way, you can use the following template to execute something at the moment the view is loaded completely:
/*Estou assumindo que o módulo do controller já está declarado*/
.controller('MeuController', function ($scope) {
$scope.$on('$viewContentLoaded', function () {
//Alterar meta tags com jQuery
});
});
But the biggest problem is that views only change meta tags if they are loaded, so as Search Engines crawlers do not execute JavaScript, the changed tags will not be captured by crawlers; physical pages are needed for this, unfortunately.
After reading the text from this link , I noticed that the crawler Google can read and execute javascript, however, this javascript MUST be on the same page. In short, the link did the following tests:
Use of document.write()
within <script></script>
in a single HTML file = Crawler read.
Use of document.write()
in a file .js
external = Crawler did not read.
Use of innerHTML
within <script></script>
in a single HTML file = Crawler read.
Use of innerHTML
in a file .js
external = Crawler did not read.
Using tabs with jQuery = Crawler read, and associated all content with just one page.
Using tabs with AJAX = Crawler read, but attached each tab to a page of its own.
In general, the best idea is to put in the <meta>
tags what you want to be indexed, even if part of what's in the tags is in the views, not the homepage itself.