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


TypeScript Renderer.setElementAttribute方法代碼示例

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


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

示例1: creatCanvas

  /**
   * 獲得一個canvas
   * @param  {Renderer} renderer 一個renderer
   * @param  {string} elem canvas的父元素的字符
   * @param  {string} width='800px' 畫布寬度
   * @param  {string} height='600px' 畫布高度
   * @param  {string} bgColor='' 畫布背景色
   */
  creatCanvas(renderer: Renderer, elem: string, width = '800', height = '600', bgColor = '', bgImg?: any) {
    let gamev = document.createElement('canvas');

    renderer.setElementStyle(gamev, 'display', 'block');
    renderer.setElementAttribute(gamev, 'width', width);
    renderer.setElementAttribute(gamev, 'height', height);
    renderer.setElementStyle(gamev, 'position', 'absolute');
    renderer.setElementStyle(gamev, 'left', '0');
    renderer.setElementStyle(gamev, 'top', '0');

    renderer.setElementStyle(gamev, 'zIndex', '10000');
    renderer.setElementStyle(gamev, 'margin', '0 auto');
    renderer.setElementStyle(gamev, 'backgroundColor', bgColor);
    if (bgImg) {
      renderer.setElementStyle(gamev, 'backgroundImage', `url(${bgImg})`);
    }

    let prarentElement = renderer.selectRootElement(elem);
    renderer.projectNodes(prarentElement, [gamev]);

    this.width = parseInt(width);
    this.height = parseInt(height);
    this.glCanvas = gamev.getContext('2d');
    
    this.mydraw.setglCanvas(this.glCanvas);
  }
開發者ID:LenGong,項目名稱:LenGong.github.io,代碼行數:34,代碼來源:frame.ts

示例2: build

    build(): void {
        this.body = document.body;

        let anchor = this.renderer.createElement(this.body, 'a');
        this.renderer.setElementStyle(anchor, 'visibility', 'hidden');
        this.renderer.setElementAttribute(anchor, 'href', 'data:text/csv;charset=utf-8,' + encodeURIComponent(this.csvData));
        this.renderer.setElementAttribute(anchor, 'target', '_blank');
        this.renderer.setElementAttribute(anchor, 'download', this.filename);

        setTimeout(() => {
            this.renderer.invokeElementMethod(anchor, 'click');
            this.renderer.invokeElementMethod(anchor, 'remove');
        }, 15);
    }
開發者ID:finleysg,項目名稱:bhmc,代碼行數:14,代碼來源:download-csv.component.ts

示例3: constructor

 constructor(
   public platform: Platform,
   public elementRef: ElementRef,
   public renderer: Renderer) {
   this.isAndroid = platform.is('android');
   renderer.setElementAttribute(elementRef.nativeElement, 'primary', this.isAndroid ? '' : null);
 }
開發者ID:GECOR,項目名稱:gecor-generic-2016,代碼行數:7,代碼來源:global.helpers.ts

示例4: validate

  validate(): void {
    let valid = this.validationService.validate(this.field, this.checkValue);

    this.field.valid = valid;
    let error = this.field.validationErrors.toString();

    this.renderer.setElementClass(this.el.nativeElement, 'validation-bad', !valid);
    this.renderer.setElementAttribute(this.el.nativeElement, 'title', error);
  }
開發者ID:uhlibraries-digital,項目名稱:brays,代碼行數:9,代碼來源:validate.directive.ts

示例5: onClick

  @HostListener('click')
  onClick() {
    let copied;
    if (this.copyText) {
      copied = Clipboard.copyCustom(this.copyText);
    } else {
      copied = Clipboard.copyElement(this.copyElement);
    }

    if (copied) {
      this.renderer.setElementAttribute(this.element.nativeElement, 'data-hint', 'Copied!');
    } else {
      let hintElem = this.hintElement || this.copyElement;
      if (!hintElem) return;
      this.renderer.setElementAttribute(hintElem, 'data-hint', 'Press "ctrl + c" to copy');
      this.renderer.setElementClass(hintElem, 'hint--top', true);
      this.renderer.setElementClass(hintElem, 'hint--always', true);
    }
  }
開發者ID:ajeetkanojia,項目名稱:ReDoc,代碼行數:19,代碼來源:copy-button.directive.ts

示例6: ngOnInit

    ngOnInit() {
        console.log('start', this.inputAttribut);
        console.log('mode', this.inputAttribut.mode);
        console.log('iod', this.inputAttribut.iod);
        if ((this.inputAttribut.code in Globalvar.IODPLACEHOLDERS) && _.hasIn(Globalvar.IODPLACEHOLDERS[this.inputAttribut.code], this.inputAttribut.mode)){
            if (Globalvar.IODPLACEHOLDERS[this.inputAttribut.code][this.inputAttribut.mode].action === 'replace' && this.el.nativeElement.tagName === 'INPUT'){
                this.renderer.setElementAttribute(this.el.nativeElement, 'placeholder', Globalvar.IODPLACEHOLDERS[this.inputAttribut.code][this.inputAttribut.mode].placeholder);
                this.renderer.setElementAttribute(this.el.nativeElement, 'title', Globalvar.IODPLACEHOLDERS[this.inputAttribut.code][this.inputAttribut.mode].placeholder);
            }
            if (Globalvar.IODPLACEHOLDERS[this.inputAttribut.code][this.inputAttribut.mode].action === 'disable'){
                this.disableElement();
            }
        }else{
            if (this.inputAttribut.iod && !_.hasIn(this.inputAttribut.iod, this.inputAttribut.code)){
                this.disableElement();
            }
            this.renderer.setElementAttribute(this.el.nativeElement, 'placeholder', this.inputAttribut.name);
        }

    }
開發者ID:PyJava1984,項目名稱:dcm4chee-arc-light,代碼行數:20,代碼來源:placeholderchanger.directive.ts

示例7: changeColor

 changeColor(color:number){
   // this.renderer.setElementAttribute(this.elementRef.nativeElement, 'fill', this.hotDeploymentService.RGBToHex(color, 255, 255));
   this.renderer.setElementAttribute(this.elementRef.nativeElement, 'fill', 'rgba(255, 0, 0,'+color+')');
 }
開發者ID:dimapod,項目名稱:xc-dashboard,代碼行數:4,代碼來源:lamp.directive.ts

示例8: expand

 private expand(rows: number): void {
     this.renderer.setElementAttribute(this.el.nativeElement, 'rows', rows.toString());
 }
開發者ID:Kraigo,項目名稱:TimeTracker,代碼行數:3,代碼來源:expand-focus.directive.ts

示例9:

 this.loadAndRender(this.phContent, (s) => {
   this.renderer.setElementAttribute(this.el.nativeElement, 'placeholder', s);
 });
開發者ID:asqwrd,項目名稱:ng2-i18next,代碼行數:3,代碼來源:i18n-directive.ts

示例10: ngOnInit

 ngOnInit () {
   if (!Clipboard.isSupported()) {
     this.element.nativeElement.parentNode.removeChild(this.element.nativeElement);
   }
   this.renderer.setElementAttribute(this.element.nativeElement, 'data-hint', 'Copy to Clipboard!');
 }
開發者ID:jwilander,項目名稱:ReDoc,代碼行數:6,代碼來源:copy-button.directive.ts


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