设置自定义验证|纸张元素0.0.6.0 + 4中的新纸张输入/纸张输入装饰器组件

时间:2014-12-22 03:34:10

标签: dart dart-polymer paper-elements

我的纸张输入上的自定义验证不再适用于新的纸张输入/纸张输入装饰器组件。

我有以下内容,但未触发验证。

.dart

import 'package:polymer/polymer.dart';
import 'package:paper_elements/paper_input_decorator.dart';
import 'package:paper_elements/paper_button.dart';
import 'package:core_elements/core_input.dart';
import 'package:core_elements/core_icon.dart';

import 'package:epimss_reg/epimss_reg.dart' show Language;
import 'package:epimss_shared/epimss_shared.dart';

import 'dart:html';

/// A Polymer `<main-app>` element.
@CustomTag('main-app')
class MainApp extends PolymerElement {


  PaperButton pprBtn;
  CoreIcon coreIcon;

  /// Constructor used to create instance of MainApp.
  MainApp.created() : super.created();


  void onInputHandler(e)
  {
    var decorator = $['first-input-decor'] as PaperInputDecorator;
    var input = $['first'] as CoreInput;

    //bool invalid = decorator.isInvalid = !input.validity.valid;
    print(input.value.length);
    if (input.value.length <= 6  )
       {
          input.setCustomValidity("Give me more!");

       }
    else
      {
         input.setCustomValidity('');
      }

  }

  @override
  void attached()
  {
    super.attached();
    pprBtn = $['ppr-btn'];
    coreIcon = $['core-icon'];
  }
}

html的

<!-- import polymer-element's definition -->
<link rel='import' href='../../packages/polymer/polymer.html'>

<link rel='import' href='../../packages/paper_elements/paper_button.html'>
<link rel='import' href='../../packages/paper_elements/paper_input.html'>
<link rel='import' href='../../packages/paper_elements/paper_input_decorator.html'>

<link rel='import' href='../../packages/core_elements/core_icons.html'>
<link rel='import' href='../../packages/core_elements/core_icon.html'>

<polymer-element name='main-app'>
  <template>
    <style>
      :host {
        display: block;
      }
    </style>

    <p>
        <paper-button 
            id='ppr-btn'
        label='button'>
            <core-icon
                id='core-icon'
             icon='refresh'></core-icon>

            My Button</paper-button>
    </p>

    <p>
   <paper-input-decorator floatingLabel validateImmediately
     id='first-input-decor'
     label='First'>
     <input required is='core-input'
        id='first'
        value='{{language.first}}'
        on-input='{{onInputHandler}}'
        error='Input is requried'>

   </paper-input-decorator>
    </p>

  </template>
  <script type='application/dart' src='main_app.dart'></script>
</polymer-element>

我似乎无法将装饰器上的验证与输入相关联。

由于

0 个答案:

没有答案