首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Angular 2-如何捕获子输入元素的接触值

Angular 2-如何捕获子输入元素的接触值
EN

Stack Overflow用户
提问于 2017-01-30 17:48:02
回答 1查看 779关注 0票数 1

我正在尝试使用ng2-datepicker,但是我没有从input元素得到触摸到的响应。datepicker-input被标记为已触摸,但它不会反弹到Angular。

代码语言:javascript
复制
<ng2-datepicker class="form-control ng-untouched ng-pristine ng-invalid" formcontrolname="datefound" _nghost-lur-40="" ng-reflect-name="datefound">
  <div _ngcontent-lur-40="" class="datepicker-container u-is-unselectable">
    <div _ngcontent-lur-40="" class="datepicker-input-container">
      <input _ngcontent-lur-40="" class="datepicker-input ng-untouched ng-pristine ng-valid" type="text">
      <div _ngcontent-lur-40="" class="datepicker-input-icon">
        <i _ngcontent-lur-40="" class="ion-ios-calendar-outline"></i>
      </div>
    </div>
    <!--template bindings={
  "ng-reflect-ng-if": null
}-->
  </div>
  </ng2-datepicker>

在Angular 2中有没有一种方法可以获取datepicker-input并附加onTouchedCallback操作?我不想修改ng2-datepicker模块,所以我想从父模块中完成所有代码。

我可以做类似下面的事情吗:- form.get('datefound')('.datepicker-input').touched

EN

回答 1

Stack Overflow用户

发布于 2017-01-31 12:29:03

然而,这不是最好的答案!为了解决这个问题,我更新了模块本身(我不想做的事情),添加了以下内容:

这触发了所需的操作,然后使我能够正确地进行验证。

这不是我最初想要的,但这是我目前的解决方案。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41932860

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档