Angular 2+中ApplicationRef的目的是什么? [英] What is the purpose of ApplicationRef in Angular 2+?

查看:96
本文介绍了Angular 2+中ApplicationRef的目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不了解 ApplicationRef 类及其用途.拥有"对在页面上运行的Angular应用程序的引用是什么意思?什么时候需要?

I don't understand the ApplicationRef class and its uses. What does it mean to have a "reference to an Angular application running on a page"? When is this needed?

请提供一个使用 ApplicationRef 的小示例.

Please provide a small example using ApplicationRef.

推荐答案

https://angular.io/api/core/ApplicationRef

  • 允许通过调用 appRef.tick()
  • 来调用应用程序范围内的更改检测
  • 它允许使用 attachView() detachView()
  • 添加/删除要包含在更改检测中或从更改检测中排除的视图
  • 使用 componentTypes components 提供已注册组件和组件类型的列表以及其他一些与变更检测相关的信息
  • allows to invoke application-wide change detection by calling appRef.tick()
  • it allows to add/remove views to be included in or excluded from change detection using attachView() and detachView()
  • provides a list of registered components and component types using componentTypes and components and some other change detection related information

这篇关于Angular 2+中ApplicationRef的目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆