I am tying to get this simple routing to work and can't figure out what is the problem.
This is the HTML:
<html lang="en" ng-app="app">
.
.
.
<a href="#voip">
<div class="col-lg-3 service">
<img src="assets/img/voip.svg"/>
<h4 ng-bind-html="content.home.voip_header"></h4>
<p ng-bind-html="content.home.voip_txt"></p>
</div>
</a>
<section id="view">
<div ng-view></div>
</section>
This is the routing:
var app = angular.module('app',[
'ngRoute',
'ngSanitize'
]);
app.config(['$routeProvider',function($routeProvider){
$routeProvider
.when('/voip',{
templateUrl:'assets/templates/voip.html'
});
}]);
The template is loaded if I specify 'otherwise' as below. I thought maybe I am using the wrong syntax in my href attribute, but I looked everywhere and seems like this is how it should be.
.otherwise({
redirectTo:'/voip'
})
Another thing is, if I listen to $routeChangeSuccess
, the event is triggered, yet the view is not loaded.
Any ideas?
try to use exclamation marks in html5 + ajs 1.6.
for example instead of href="#home"..... write href="#!home". It worked for me after 4 hours of head scratching.
It's properly because you are using angular 1.6 and there has been a change the default hash-prefix:
So you have some options:
1. Set HTML5mode true
and in html set base in html header:
Lastly change
<a ng-href="#voip">
to2. Use the 1.6 way
Change
<a ng-href="#voip">
to
<a ng-href="#!voip">
3. Go back to old behaviour from 1.5 - set hash prefix manually