AngularJs输入[类型=日期]未显示负载值 [英] AngularJs input[type=date] not showing value on load

查看:80
本文介绍了AngularJs输入[类型=日期]未显示负载值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望您能有所帮助,因为我是AngularJs的新手. 我创建了一个显示3个字段的编辑表单模板;名称,开始日期和结束日期.数据来自使用C#编写的WebAPI控制器,并带有实体框架数据源.

I'm hoping you can help as I'm fairly new to AngularJs. I have created an edit form template that displays 3 fields; a name, a start date and an end date. The data is coming from a WebAPI controller written in C# with an entity framework data source.

表单加载后,开始数据和结束日期的输入为空白.

When the form loads the input for the start data and for the end date are blank.

所有这些都是Umbraco7后端扩展的一部分.

All of this is part of an extension to the Umbraco7 back end.

如何获取日期输入以填充并保持数据与模型的绑定?

How can I get my date inputs to populate and keep the data binding to my model?

这是我的表格:

This is my form:

            </div>
            <div class="span5">
                <div class="btn-toolbar pull-right umb-btn-toolbar">
                    <umb-options-menu ng-show="currentNode"
                                      current-node="currentNode"
                                      current-section="{{currentSection}}">
                    </umb-options-menu>
                </div>
            </div>
        </umb-header>
        <div class="umb-panel-body umb-scrollable row-fluid">
            <div class="tab-content form-horizontal" style="padding-bottom: 90px">
                <div class="umb-pane">
                    <umb-control-group label="Start Date" description="The date the event starts">    
                        <input type="text" class="umb-editor umb-textstring" ng-model="event.StartDate" required/>
                    </umb-control-group>
                    <umb-control-group label="End date" description="The date the event finishes">
                        <input type="date" class="umb-editor umb-textstring" ng-model="event.EndDate" required/>
                    </umb-control-group>
                    <div class="umb-tab-buttons" detect-fold>
                        <div class="btn-group">
                            <button type="submit" data-hotkey="ctrl+s" class="btn btn-success">
                                <localize key="buttons_save">Save</localize>
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </umb-panel>
</form>

我检查了事件是否到来时,通过检查控制台填充了所有字段,我还尝试过仅将输入作为文本并显示值.

I've checked that when the event comes in that all the fields are populated by examining the console, I've also tried just having the input as text and the values show.

在上面的代码中,我将开始日期保留为正在填充的文本输入,但没有结束日期

In the code above I've left the start date as a text input which is populating, but the end date isn't

但是,如果我设置它们并单击将模型保存在后台更新中.

Yet if I set them and click save the model in the background updates.

任何帮助将不胜感激.

推荐答案

Umbraco 7.2.4(迄今为止的最新版本)使用Angular 1.1.5
角度ng模型绑定不适用于input[type="date"] 直到版本1.3
看看这个SO问题更多细节.

Umbraco 7.2.4 (the most recent release until today) uses Angular 1.1.5
Angular ng-model binding does not work with input[type="date"] until version 1.3
take a look at this SO question for more details.

因此,您可能要考虑升级到angular 1.3,但不确定是否在Umbraco中不会破坏任何内容.或者只是坚持input[type="text"]

So you may want to consider upgrading to angular 1.3, not sure if it won't break anything in Umbraco though. Or just stick to input[type="text"]

HTH

这篇关于AngularJs输入[类型=日期]未显示负载值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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