• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript core.Component函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript core.HostBinding函数代码示例发布时间:2022-05-28
下一篇:
TypeScript xhr_mock.MockXHR类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap