I was using AngularJs-1.0.7 and Bootstrap in my application. Recently I migrated from AngularJs-1.0.7 to AngularJs-1.2. I am using Bootstrap\'s Accordions and Tabs.
credits to https://prerender.io/js-seo/angularjs-seo-get-your-site-indexed-and-to-the-top-of-the-search-results/
My solution: - inside app.js try adding "$locationProvider.hashPrefix('!');"
.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider',
function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) {
$stateProvider
.state('menu', {
url: '/',
cache: false,
abstract: true,
templateUrl: 'static/www/templates/menu.html'
})
.state('menu.main_page', {
url: 'app/main',
cache: false,
views: {
'menuContent': {
templateUrl: 'static/www/templates/mainpage.html',
controller: 'MainCtrl'
}
}
})
$locationProvider.hashPrefix('!');
$urlRouterProvider.otherwise(function ($injector, $location) {
var $state = $injector.get('$state');
$state.go('menu.mainpage');
});
}])
inside index.html try adding
and as Marcel said above
.directive('a', function () {
return {
restrict: 'E',
link: function (scope, elem, attrs) {
if (attrs.href && attrs.href.indexOf('#') > -1) {
elem.on('click', function (e) {
e.preventDefault();
});
}
}
};
})
that's all! works for me!