怎么样,我想全局处理http错误(特别是状态401).我知道我可以做那样的事情
getCompanies() {
return this.http.get('https://angular2.apispark.net/v1/companies/')
.map(res => res.json())
.catch(res => {
return Observable.throw(res.json());
});
Run Code Online (Sandbox Code Playgroud)
如何在其他组件上获得此错误?
只是为了解释我想实现所有401错误将用户重定向到登录页面
任何人都可以帮助理解之间的差异$rootScope.$new()和$rootScope.$new(true)?根据我的理解,它们应该是相同的,因为$rootScope没有父范围.