【发布时间】:2015-03-03 12:30:37
【问题描述】:
我的任务是使用 AngularDart 创建一个 web 应用程序。我是 Dart 的新手,因此也是 AngularDart 的新手,但我已经完成了 https://angulardart.org/tutorial/ 的教程。
我已经阅读过类似的 SO 问题/答案 (How to access a AngularDart components attribute (NgOneWay) outside of the component, eg. on the page it is in?),但鉴于我的知识有限,我并不完全理解如何实施 Brian 的建议——或者如果它确实与我的问题有关!我是否也认为 Vink 的建议现在与 @Controller 已被弃用无关?
简而言之,我试图弄清楚以下是否真的可以实现:
- 创建一个包含属性的顶级
<custom-component/>; - 在
<ng-view/>内——因此是嵌套组件——访问<custom-component/>的属性。更具体地说,绑定/侦听对这些属性的更改并采取相应措施。
例如,给定以下
<body>
<custom-component att1="val1" att2="val2"></custom-component>
<ng-view></ng-view>
</body>
并假设<ng-view/> 呈现以下标记
<div>
...
<other-component att1="{{customComponent.att1}}" att2="{{customComponent.att2}}"></other-component>
<another-component att1="{{customComponent.att1}}" att2="{{customComponent.att2}}"></another-component>
...
</div>
是否可以将customComponent.<<attributeName>> 绑定到<other-component/> 和<another-component/>?
或者,很可能,我误解了 AngularDart 的 @Component/@Decorator 的使用?
是否应该将@att1 和@att2 属性从<custom-component/> 移动到<ng-view/>?
或者,我应该寻求完全不同的解决方案吗?在这种情况下,我的最终目标是为用户提供att1/att2 选择框(来自另一个组件),这反过来又确定了<other-component/> 和<another-component/> 中的每个渲染内容。
欢迎任何和所有建议,如果您忽略以上任何/所有建议,我不会被冒犯!!!
我目前的开发环境如下:
- Dart SDK 版本 1.9.0-dev.8.0
- 角度 1.0.0
非常感谢,J
【问题讨论】:
标签: dart angular-dart