當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript core.Component函數代碼示例

本文整理匯總了TypeScript中@angular/core.Component函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Component函數的具體用法?TypeScript Component怎麽用?TypeScript Component使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Component函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: Component

const createComponentFromTemplate = (template: string): Function => {
  const componentClass = class DynamicComponent {};

  return Component({
    template: template,
  })(componentClass);
};
開發者ID:lyndontavares,項目名稱:storybook,代碼行數:7,代碼來源:helpers.ts

示例2: IconComponent

var IconComponent = (function () {
    function IconComponent() {
        this.vAlign = 'center';
        this.hAlign = 'center';
        this.fontSize = "16px";
    }
    Object.defineProperty(IconComponent.prototype, "charName", {
        get: function () {
            return String.fromCharCode(iconList_1.iconList[this.iconName]);
        },
        enumerable: true,
        configurable: true
    });
    __decorate([
        core_1.Input('name'), 
        __metadata('design:type', Number)
    ], IconComponent.prototype, "iconName", void 0);
    __decorate([
        core_1.Input('vertical-align'), 
        __metadata('design:type', Object)
    ], IconComponent.prototype, "vAlign", void 0);
    __decorate([
        core_1.Input('horizontal-align'), 
        __metadata('design:type', Object)
    ], IconComponent.prototype, "hAlign", void 0);
    IconComponent = __decorate([
        core_1.Component({
            selector: 'Icon',
            template: "<Label style=\"font-size:{{fontSize}};horizontal-align:{{hAlign}};vertical-align:{{vAlign}};font-family:fontawesome\" [text]=\"charName\" ></Label>"
        }), 
        __metadata('design:paramtypes', [])
    ], IconComponent);
    return IconComponent;
}());
開發者ID:abuda7em,項目名稱:nativescript-fontawesome,代碼行數:34,代碼來源:icon.ts

示例3: createComponentFactory

  createComponentFactory(resolver: ComponentResolver, metadata: ComponentMetadata): Promise<ComponentFactory<any>> {
    // Define component to create
    const cmpClass =  class DynamicComponent {};

    // Define component and metadata(ie @Component())
    const decoratedCmp = Component(metadata)(cmpClass);

    // Return ComponentFactory to create components with
    return resolver.resolveComponent(decoratedCmp);
  }
開發者ID:jmcclanahan,項目名稱:dynamic-component-generator,代碼行數:10,代碼來源:dynamicHtmlOutlet.directive.ts

示例4: createComponentFactory

export function createComponentFactory(resolver: ComponentResolver, metadata: ComponentMetadata): Promise<ComponentFactory<any>> {
    const cmpClass = class DynamicComponentA {
        login(modelValue: any): Observable<boolean> | boolean {
            console.log("dynamicLoginComponent:" + JSON.stringify(modelValue));
            return false;
        }
    };
    const decoratedCmp = Component(metadata)(cmpClass);
    return resolver.resolveComponent(decoratedCmp);
}
開發者ID:RandyBoy,項目名稱:new-router,代碼行數:10,代碼來源:DynamicHTMLOutlet.ts

示例5: ensureName

  return <T extends Manifest, Instance>(target: T & (new (...args: any[]) => {
    [P in keyof Instance]: Instance[P]
  })) => {
    ensureName(target);
    const componentOptions = (
      typeof styleOrOptions !== 'string' && styleOrOptions ||
      typeof styleOrOptions === 'string' && options || {}
    ) as ComponentOptions & {
      template: string, styles?: string[], selector: string
    };

    componentOptions.selector = kebabCase(target.name, 'Component');
    componentOptions.styles = typeof styleOrOptions === 'string' && [styleOrOptions] || undefined;
    componentOptions.template = template;
    return Component(componentOptions)(target);
  };
開發者ID:aluanhaddad,項目名稱:ng2-conventions-decorators,代碼行數:16,代碼來源:index.ts

示例6: test_comp_html

 // a component template for testing other components, by full html template
 test_comp_html(tmplt, cls, obs_pars = {}, static_pars = {}, outputs = {}) {
   let cmp = class {
     constructor() {
       for (let k in obs_pars) this[k] = new BehaviorSubject(obs_pars[k]);
       for (let k in static_pars) this[k] = static_pars[k];
       for (let k in outputs) this[k] = outputs[k];
     }
   };
   Reflect.decorate([Component({
     // selector: 'test',
     directives: [cls],
     template: tmplt,
   })], cmp);
   Reflect.decorate([ViewChild(cls)], cmp.prototype, 'comp');
   return cmp;
 }
開發者ID:tycho01,項目名稱:react-storybook,代碼行數:17,代碼來源:client_api.ts

示例7: createDynamicComponent

export function createDynamicComponent(resolver: ComponentResolver, metadata: ComponentMetadata, context: any = {}): Promise<ComponentFactory<any>> {
    const cmpClass = class dynamicComponent {
        constructor() {
            if ('dynamicOnInit' in this) {
                (this as any)['dynamicOnInit'](this);
            }
        }
    };
    (cmpClass.prototype as any)['dynamicOnInit'] = (self: any) => {
        Object.keys(context).forEach(key => {
            self[key] = context[key];
        });
    };
    const decoratedCmp = Component(metadata)(cmpClass);
    return resolver.resolveComponent(decoratedCmp as Type);
}
開發者ID:laco0416,項目名稱:angular2-commons,代碼行數:16,代碼來源:dynamic-component-factory.ts

示例8: MockComponent

export function MockComponent(options: Component): Component {
  const metadata: Component = {
    selector: options.selector,
    template: options.template || '',
    inputs: options.inputs,
    outputs: options.outputs || [],
    exportAs: options.exportAs || '',
  };

  class Mock {}

  metadata.outputs.forEach(method => {
    Mock.prototype[method] = new EventEmitter<any>();
  });

  return Component(metadata)(Mock as any);
}
開發者ID:formly-js,項目名稱:ng2-formly,代碼行數:17,代碼來源:test-utils.ts

示例9: MockComponent

export function MockComponent(options: Component, spies: string[] = []) {
  let metadata: Component = {
    selector: options.selector,
    template: options.template || '',
    inputs: options.inputs,
    outputs: options.outputs
  };
  let component = class _ {};
  if (options.outputs) {
    for (let output of options.outputs) {
      component.prototype[output] = new EventEmitter<any>();
    }
  }
  for (let spy of spies) {
    component.prototype[spy] = jasmine.createSpy(spy);
  }
  return Component(metadata)(component);
}
開發者ID:iamthelogik83,項目名稱:front,代碼行數:18,代碼來源:mock.ts

示例10: createComponentFactory

export function createComponentFactory(compiler: Compiler,
                                       metadata: Component):
                                              Promise<ComponentFactory<any>> {
    const cmpClass = class DynamicComponent {};
    const decoratedCmp = Component(metadata)(cmpClass);

    @NgModule({ 
        imports: [ CommonModule ], 
        declarations: [decoratedCmp],
        schemas: [ CUSTOM_ELEMENTS_SCHEMA ] })
    class DynamicHtmlModule { }

    return compiler.compileModuleAndAllComponentsAsync(DynamicHtmlModule)
       .then((moduleWithComponentFactory: ModuleWithComponentFactories<any>) => 
                {
                    return moduleWithComponentFactory.componentFactories.find
                                ((x) => x.componentType === decoratedCmp);
                });
}
開發者ID:brakmic,項目名稱:Angular_VRDemo,代碼行數:19,代碼來源:component-factory.ts


注:本文中的@angular/core.Component函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。