I have create 2 angular app into drupal 7 like "example.com", "example.com/app1", "example.com/app2".
example.com is my main site. So, when I set html5 pushstate enable for removing hash in angular apps, I got nobase error from angularjs. Coz,
<base href="">
require for enable angularjs html5 pushstate.
My question is, since i have multiple angualr app in this drupal site, how can i dynamically add conditional base url for "/app1" and "app2" ?
anybody can help me? Waiting for response. Thanx.
You can add base element to your site in this way:
YOUR_THEME_NAME_preprocess_html(&$variables, $hook) {
$url = 'default';// default url
if($application1) {// your condition for app1
$url = 'app1';
} elseif($application2) {// your condition for app2
$url = 'app2';
}
$data = array(
'#tag' => 'base',
'#attributes' => array(
'href' => $url,
),
);
drupal_add_html_head($data, 'base_href');
}
Put it into your template.php