小编Ric*_*ky 的帖子

Angular 2如何显示.pdf文件

我有一个angular2应用程序,我希望用户能够在浏览器中下载和打开pdf文件.

我可以使用angular2模块或组件吗?

pdf angular

20
推荐指数
3
解决办法
6万
查看次数

以角度2格式化日期时间

如何在Angular2中显示日期时间?

{{DTE}}

它打印日期2014-10-10T11:42:28.000Z

虽然我需要它打印像

2015年10月10日

angular

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

Angular 6 @Viewchild不支持延迟加载

这是我的代码,给出错误无法读取属性标题undefined.

父组件

import { Child } from './child.component';
@Component({
  selector: 'parent',
})
export class ParentComponet implements OnInit, AfterViewInit {
 constructor(){}

  @ViewChild(Child) child: Child;

  ngAfterViewInit(){
    console.log("check data", this.child.title)
  }
}
Run Code Online (Sandbox Code Playgroud)

和儿童组件是.

@Component({
      selector: 'child',
    })
    export class ChildComponet {

     public title = "hi"
     constructor(){}

    }
Run Code Online (Sandbox Code Playgroud)

routing.module.ts就像

{
        path: "",
        component: ParentComponent,
        children: [
            {
                path: '/child',
                component: ChildComponent
            }
        ]
}
Run Code Online (Sandbox Code Playgroud)

并且给出了错误

ERROR TypeError: Cannot read property 'title' of undefined(…)
Run Code Online (Sandbox Code Playgroud)

javascript lazy-loading angular angular6

8
推荐指数
1
解决办法
2059
查看次数

如何将之前的路线作为 Angular 中的路径?

如何将之前的路线作为 Angular 中的路径?

我尝试通过此链接使用解决方案,但它不会在首页加载时执行。

constructor(router: Router) {
  router.events
  .pipe(filter(event => event instanceof NavigationEnd))
  .subscribe((event: NavigationEnd) => {
    console.log('prev:', event.previousUrl);
    this.previousUrl = event.url;
  });
}
Run Code Online (Sandbox Code Playgroud)

我使用了RoutesRecognizedNavigationEnd,但是它们不起作用。

我在 constructor 和中调用了这个方法ngOnInit,但是它们都没有在首页加载时执行。

有没有办法获取之前的URL?

谢谢。

javascript routes typescript angular-routing angular

8
推荐指数
2
解决办法
2万
查看次数