简体   繁体   English

如何使用ngrx / store更改angular中输入字段的值

[英]How do I change the value of an input field in angular using ngrx/store

I have a backgroundHex key/value in my ngrx/store for my colors object. 我的ngrx / store中有我的color对象的backgroundHex键/值。 So to access it in my app I would do the following {{(colors | async).backgroundHex)}} 因此,要在我的应用中访问它,我将执行以下{{(colors | async).backgroundHex)}}

The above works quite well, but when it comes to input fields I've been having a hard time finding the right syntax in a timely fashion and I was wondering if someone could help. 上面的方法效果很好,但是在输入字段方面,我一直很难及时找到正确的语法,我想知道是否有人可以提供帮助。 I've tried value, ngModel, and ngModelChanged(perhaps not in the right way). 我已经尝试过值,ngModel和ngModelChanged(也许不是正确的方式)。

Any help would be incredibly helpful. 任何帮助都将非常有用。 Thank you. 谢谢。

It turns out that it is really simple. 事实证明,这确实很简单。 Assuming you have the store properly hooked up into the component, the following is will work: 假设您已将商店正确地连接到组件中,则可以进行以下操作:

value="{{(colors | async).backgroundRed}}"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM