You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
When I use the $httpProvider's interceptor, it will prevent the component in the ngView to be loaded.
If I remove the interceptor, it will be ok.
Well, it sounds confusing. So Let's check the code.
Here is my code:
functionAppController(){}functionNavController(){}angular.module('httpApp',['ngRoute']).config(['$routeProvider','$httpProvider',function($routeProvider,$httpProvider){$routeProvider.when('/nav1',{template: '<nav1></nav1>'}).when('/nav2',{template: '<nav2></nav2>'}).otherwise('/nav1');// If I uncomment the interceptor, // it will prevent the component to be loaded.$httpProvider.interceptors.push(['$q','$location',function($q,$location){return{'request': function(config){config.headers=config.headers||{};returnconfig;},'requestError': function(config){returnconfig;},'response': function(response){returnresponse;},'responseError': function(response){return$q.reject(response);}};}]);}]).component('app',{templateUrl: 'app.html',controller: AppController}).component('nav1',{template: '<div><h4>This is <em>Nav1</em> View<h4></div>',controller: NavController}).component('nav2',{template: '<div style="color: red"><h4>This is <em>Nav2</em> View<h4></div>',controller: NavController});;
This is a known issue. It has been fixed on master (the fix will be included in the 1.6 release). You can find more context in #14893 (and the issues/commits/PR linked from there).
To make it work with v1.5.7, you can instantiate the $route service yourself. E.g. add:
_Angularjs: 1.5.7_
_ngRoute: 1.5.7_
When I use the $httpProvider's interceptor, it will prevent the component in the ngView to be loaded.
If I remove the interceptor, it will be ok.
Well, it sounds confusing. So Let's check the code.
Here is my code:
index.html
app.js
app.html
Here is the result.

And Following is expected(_Just switch the nav to see the result_):

Here is the live preview link https://plnkr.co/edit/LxtA1hRjuJ0MiymazWmD?p=preview
The text was updated successfully, but these errors were encountered: