Angular 2 - 仅在循环中对一个字段进行反应形式验证

时间:2017-05-12 09:40:16

标签: angular typescript

我正在数组中构建一个表单:

def invokeAny(work: Seq[() => Int]): Int = {
    @volatile var result = 0 // set to return value of any work function
    val main = Thread.currentThread()

    var threads: Seq[Thread] = Seq()

    //Interrupts all threads after one is interrupted
    def interruptAll = {
      main.interrupt()
      for(thread <- threads) {
        thread.interrupt()

      }
    }

    threads = work.map(work => new Thread( 
        new Runnable { 
          def run {
            result = try {
              work() } catch {
                case e:InterruptedException => return
            }
            interruptAll;  

            }
          }))

    threads.foreach(_.start())
    for(thread <- threads) {
      try {
        thread.join()
      } catch {
        // We've been interrupted: finish
        case e: InterruptedException =>  return result
    }
    }
    return result
  }

但我只是将验证放在第一个&#34;姓氏&#34;上,从阵列中产生的所有其他姓氏都没有验证。 这是一个简单的例子,看看索引是否等于0还是有更优雅的方式?

0 个答案:

没有答案
相关问题