文档: https://angular.io/guide/template-syntax#event-binding

The Angular compiler may reject these bindings with errors like this one:

content_copyUncaught Error: Template parse errors:
Can't bind to 'hero' since it isn't a known property of 'app-hero-detail'

You know that HeroDetailComponent has hero and deleteRequest properties. But the Angular compiler refuses to recognize them.

The Angular compiler won't bind to properties of a different component unless they are Input or Output properties.

There's a good reason for this rule.

It's OK for a component to bind to its own properties. The component author is in complete control of those bindings.

But other components shouldn't have that kind of unrestricted access. You'd have a hard time supporting your component if anyone could bind to any of its properties. Outside components should only be able to bind to the component's public binding API.

Angular asks you to be explicit about that API. It's up to you to decide which properties are available for binding by external components.

TypeScript public doesn't matterlink

You can't use the TypeScript public and private access modifiers to shape the component's public binding API.

All data bound properties must be TypeScript public properties. Angular never binds to a TypeScript privateproperty.

Angular requires some other way to identify properties that outside components are allowed to bind to. That other way is the @Input() and @Output() decorators.

最新文章

  1. PHP多级联动的学习(一)
  2. http协议(四)http状态码
  3. [Asp.Net]状态管理(ViewState、Cookie)
  4. python 中time.sleep没有作用
  5. alpha阶段总结 说明
  6. 微软Office与金山WPS Office有何私密关系?
  7. xml中的特殊符号
  8. 关于DDS的基础知识
  9. heat-engine组件
  10. Windows下Oracle 11g的下载与安装
  11. 数据仓库:Mysql大量数据快速导出
  12. Learning-Python【13】:迭代器和生成器
  13. SSL、数字签名、CA 工作原理通俗描述
  14. 每天定时备份mysql数据库任务
  15. MFC和GTK的区别
  16. ArcGIS Javascript 图层事件绑定
  17. App Extension的脱壳办法
  18. 试题 B: 不同子串 蓝桥杯
  19. Django的安装创建与连接数据库
  20. 【Linux】- Ubuntu 配置mysql远程访问

热门文章

  1. Revit二次开发示例:DeleteObject
  2. 决策树(CART)
  3. 订单超时、活动过期解决方案:php监听redis key失效触发回调事件
  4. MyBatis之MyBatis环境搭建
  5. BZOJ 3926: [Zjoi2015]诸神眷顾的幻想乡 广义后缀自动机 后缀自动机 字符串
  6. [UOJ422]小Z的礼物
  7. [POI2015]Logistyka
  8. 【洛谷】4917:天守阁的地板【欧拉函数的应用】【lcm与gcd】【同除根号优化】
  9. 90. 子集 II
  10. Codeforces Round #361 (Div. 2) B. Mike and Shortcuts bfs