當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。