如何绑定查看日期模型Angularjs毫秒 [英] How to bind View Date to model milliseconds with Angularjs
问题描述
我要Date类型的输入绑定的视图结果
在与Angularjs模型毫秒属性。
I want to bind an input of type Date on the view
to a milliseconds property in the model with Angularjs.
例如:结果
用户设置2014年9月23日到现场结果
和angularjs自动设置1411423200000结果
到模型属性与输入绑定。
For example :
the user set "09/23/2014" into the field
and angularjs automatically set "1411423200000"
into the model property binding with the input.
我没有找到任何指示或过滤器来做到这一点。
I don't find any directive or filter to do that.
感谢您的帮助。
更新细节,我的问题。
有没有Angularjs一个原生的方式拦截结果
模型视图和视图模型和转换数据?
Is there a "native" way in Angularjs to intercept
model to view AND view to model and convert my data ?
推荐答案
我找到了一个解决方案:
I found a solution with :
ngModel.$parsers.push(fromUser);
ngModel.$formatters.push(toUser);
就这样,我在结合动态改变数据格式。
With that, i change dynamically the data format during the binding.
请参阅的jsfiddle
这篇关于如何绑定查看日期模型Angularjs毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!