当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript forms.ControlArray类代码示例

本文整理汇总了TypeScript中angular2/forms.ControlArray的典型用法代码示例。如果您正苦于以下问题:TypeScript ControlArray类的具体用法?TypeScript ControlArray怎么用?TypeScript ControlArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ControlArray类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

 it("should run the validator when the value changes", () => {
   var a = new ControlArray([]);
   var c = new Control(null, Validators.required);
   a.push(c);
   expect(a.valid).toBe(false);
   c.updateValue("some value");
   expect(a.valid).toBe(true);
   expect(a.errors).toBe(null);
 });
开发者ID:gdi2290,项目名称:sample-Angular2,代码行数:9,代码来源:model_spec.ts

示例2: describe

      describe("valueChanges", () => {
        var a: ControlArray;
        var c1, c2;

        beforeEach(() => {
          c1 = new Control("old1");
          c2 = new Control("old2");
          a = new ControlArray([c1, c2]);
        });

        it("should fire an event after the value has been updated",
           inject([AsyncTestCompleter], (async) => {
             ObservableWrapper.subscribe(a.valueChanges, (value) => {
               expect(a.value).toEqual(['new1', 'old2']);
               expect(value).toEqual(['new1', 'old2']);
               async.done();
             });
             c1.updateValue("new1");
           }));

        it("should fire an event after the control's observable fired an event",
           inject([AsyncTestCompleter], (async) => {
             var controlCallbackIsCalled = false;

             ObservableWrapper.subscribe(c1.valueChanges,
                                         (value) => { controlCallbackIsCalled = true; });

             ObservableWrapper.subscribe(a.valueChanges, (value) => {
               expect(controlCallbackIsCalled).toBe(true);
               async.done();
             });

             c1.updateValue("new1");
           }));

        it("should fire an event when a control is removed",
           inject([AsyncTestCompleter], (async) => {
             ObservableWrapper.subscribe(a.valueChanges, (value) => {
               expect(value).toEqual(['old1']);
               async.done();
             });

             a.removeAt(1);
           }));

        it("should fire an event when a control is added", inject([AsyncTestCompleter], (async) => {
             a.removeAt(1);

             ObservableWrapper.subscribe(a.valueChanges, (value) => {
               expect(value).toEqual(['old1', 'old2']);
               async.done();
             });

             a.push(c2);
           }));
      });
开发者ID:B-Thapa,项目名称:angular,代码行数:56,代码来源:model_spec.ts

示例3: it

        it("should support inserting", () => {
          a.push(c1);
          a.push(c3);

          a.insert(1, c2);

          expect(a.controls).toEqual([c1, c2, c3]);
        });
开发者ID:B-Thapa,项目名称:angular,代码行数:8,代码来源:model_spec.ts

示例4: inject

           inject([AsyncTestCompleter], (async) => {
             ObservableWrapper.subscribe(a.valueChanges, (value) => {
               expect(value).toEqual(['old1']);
               async.done();
             });

             a.removeAt(1);
           }));
开发者ID:B-Thapa,项目名称:angular,代码行数:8,代码来源:model_spec.ts


注:本文中的angular2/forms.ControlArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。