Hi ,
We are facing issue with angularJs SPA, the problem seems to be with routing to the #fragments in same page when using ui-router. We configured the routes and menu items like below,
<a ui-sref="home" ng-click="CloseDrawer()"><span>Services</span></a>
<a ui-sref="map" ng-click="CloseDrawer()">^__i class="fa fa-fw fa-rupee"><span>Map</span></a>
app.config(function ($stateProvider, $urlRouterProvider) {
$urlRouterProvider.otherwise('home');
$stateProvider
.state('home',
{
url: '#home',
templateUrl: 'Templates/home.html'
}).state('services',
{
url: '#services',
templateUrl: 'Templates/home.html'
}).state('pricing',
{
url: '#map',
templateUrl: 'Templates/home.html',
controller: 'mapController'
});
});
upon click on anchor tag, based on routes router is redirecting.
My index.html / main page for SPA looks some thing like below
<body id="_body" ng-controller="RootCtrl" ng-class="DrawerClass">
<div id="main" class="container_m">
<!--
<my_drawer></my-drawer>
<div class="content-wrap" ng-click="CloseDrawer()">
<div class="content">
<!--
<my-header></my-header>
<!--
<ui-view></ui-view>
</div>
<!--
<my-footer></my-footer>
</div>
</div>
and home.html looks like below
<section id='home'>
.
.
</section>
<section id='services'>
.
.
</section>
<section id='map'>
.
<!--
.
<map></map>
.
</section>
The problem is, when ever we click on any link from menu, the controller associated with the map route is firing its init() and the url is forming like '/#/home#map'. please notice 2 hash fragments in url.
and we are initializing the map from RootController init() which is on body tag and as we click on map menu item map disappearing.
We are unable to figure out,the #fragment redirection (in Same page, with diff Divs) when using ui-router in SPA and what causing MAP to disappear in this case?
Thanks in Adv,
Harry
What I have tried:
Tried removing controller from route config and placed on map div but no use. placed hash in route as some of blog discussions suggested, to avoid extra redirection in ui-sref="#/services" but no use.