Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了如何操纵Angular Dart中的表单?大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
找不到任何解释如何在Angular Dart中操作表单的文档.

我在my_component.html中有以下代码

<form name="form" ng-submit="comp.save()">
  <input type="text" required ng-model="comp.user.firstname">
  <input type="text" required ng-model="comp.user.lastname">
  <button ng-disabled="form.invalid">Save</button>
</form>

以及my_component.dart中的以下内容

@NgComponent(
  SELEctor    : 'my-component',templateUrl : 'my_component.html',publishAs   : 'comp'
)
class MyComponent {

  @NgTwoWay('user')
  User user;

  @NgTwoWay('form')
  NgForm form;

  MyComponent() {};

  void save() {
    print(form);
  }

}

验证效果很好,但是当单击按钮时,print(form)语句始终打印为null.

任何的想法?

谢谢

解决方法

我想这就是你想要的:

class MyComponent {
  @NgTwoWay('user')
  User user = new User();

  Scope scope;

  MyComponent(this.scopE) {}

  void save() {
    var form = (scope.context['form'] as NgForm);
    print(form.invalid);
  }
}
@H_874_32@

大佬总结

以上是大佬教程为你收集整理的如何操纵Angular Dart中的表单?全部内容,希望文章能够帮你解决如何操纵Angular Dart中的表单?所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。