小编Bou*_*ule的帖子

Angular 4+:手动重定向到路由

我刚刚开始使用角度4而不是angular.js 1.

我已经按照英雄教程了解了角度4的基本原理,我目前正在使用角度自己的"@ angular/router"包中的"RouterModule".

为了实现我的应用程序的一些授权我想知道如何手动重定向到另一条路线,我似乎无法在互联网上找到任何有用的信息.

angular

69
推荐指数
3
解决办法
10万
查看次数

Angular 2动态模板url有字符串变量吗?

 @Component({
  selector: 'bancaComponent',
  templateUrl: '{{str}}'
})
export class BancaComponent implements OnInit {
  str: String;
  constructor(private http: Http) { }
  ngOnInit(): void {
  this.str = "./file.component.html";
}
Run Code Online (Sandbox Code Playgroud)

还有另一种方法吗?谢谢 :)

typescript angular2-template angular

9
推荐指数
1
解决办法
8299
查看次数

Angular 订阅/取消订阅最佳实践

我目前想知道角度订阅和取消订阅。关于这个主题有很多东西,所以我对所有这些都有点迷失。

我什么时候应该取消订阅?如果我不取消订阅会发生什么?我从未遇到过 reliquat 订阅的任何错误。

有没有办法自动取消订阅组件/应用程序中的所有内容,这样我就不必通过订阅声明 1 个属性?这可能非常烦人:

@Component({
  selector: 'subscriptionTest',
  template: `...`,
})
export class SubTestComponent {
  first;
  second;
  third;

  constructor(private remote: RemoteService){}

  ngOnInit() {
    this.first = remote.getSomeData().subscribe(data => // do something);
    this.second = Observable.interval(500).subscribe(event => // do something);
    this.third = remote.getSomeOtherData().subscribe(data => // do something);

  }

  ngOnDestroy() {
    this.first.unsubscribe();
    this.second.unsubscribe();
    this.third.unsubscribe();
  }

}
Run Code Online (Sandbox Code Playgroud)

typescript angular

5
推荐指数
2
解决办法
9980
查看次数

标签 统计

angular ×3

typescript ×2

angular2-template ×1