Reputation: 105
I am trying to make routing in angular js 1.6 but it is giving below error. By default home page is loaded properly but when I try to navigate two.html it is throwing error.
Error: [$compile:tpload] http://errors.angularjs.org/1.6.3/$compile/tpload?p0=views%2Fhome.html&p1=-1&p2=
at angular.js:38
at angular.js:19933
at angular.js:16843
at m.$digest (angular.js:17982)
at m.$apply (angular.js:18280)
at angular.js:1912
at Object.invoke (angular.js:5003)
at c (angular.js:1910)
at Pc (angular.js:1930)
at ue (angular.js:1815)
This is my app.js code
var app = angular.module("jasmineKarmaDemo", ["ngRoute"]);
app.config(['$routeProvider', function ($routeProvider) {
$routeProvider
.when("/", {
templateUrl: "views/home.html"
})
.when("/two", {
templateUrl : "two.html"
})
.otherwise("/two", {
templateUrl : "views/two.htm"
})
}]);
This is HTML code
<header>
<div>
<a href="#/">Home</a>
</div>
<div>
<a href="#two">Two</a>
</div>
</header>
It is working fine with angular js 1.5 version. Should I missing something? Thanks in advance.
Upvotes: 0
Views: 512
Reputation: 1413
Url are prefixed with !
in 1.6 version - migration guide
Something like this:
<a ng-href="#!/url">link</a>
Upvotes: 0
Reputation: 470
I think the problem is in your second route "/two",template url is "two.html", but according to other routes, I'm assuming that you've missed "views/" part, so that template doesn't exist.
Also, I think your otherwise would be better like this:
.otherwise({redirectTo:'/two'});
or is that different view?
Upvotes: 1