在AngularDart中的NgController和NgComponent之间发送消息的标准方法是什么? [英] What is the standard way to send messages between NgController and NgComponent in AngularDart?

查看:305
本文介绍了在AngularDart中的NgController和NgComponent之间发送消息的标准方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制器,需要从组件获取一些信息。每个都是通过dom创建的。我理解组件更新给他们的模型,它们可以由控制器提供。

I have a controller that needs to get some info from a component. Each are getting created by angular through the dom. I understand that components update the models that are given to them which can be provided by the controller. What is the angular way to notify the controller about those changes in the component?

推荐答案

要说控制器是一个控制器通知一个组件的变化不是真正的正确方式来思考发生了什么。

To say that you want a controller to be notified about a change from a component isn't really the correct way to think about what is going on.

在控制器中,某些类型的数据模型被表示并使用控制器的当前$ scope映射到视图。当DOM元素(从我们的术语假设的组件)想要更新控制器提供的模型时,该模型通过指令(通常为ng-model)绑定到组件。当该组件更改模型时,由于指令和数据绑定,数据会自动更新。

In the controller, some type of data model is represented and projected to a view using the current $scope of the controller. When a DOM element (component I'm assuming from your terminology) wants to update the model that the controller is providing, that model is bound via a directive (commonly ng-model) to a component. When that component changes the model, the data is updated automatically because of the directive and the data binding.

这篇关于在AngularDart中的NgController和NgComponent之间发送消息的标准方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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