本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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+')');
}
示例8: expand
private expand(rows: number): void {
this.renderer.setElementAttribute(this.el.nativeElement, 'rows', rows.toString());
}
示例9:
this.loadAndRender(this.phContent, (s) => {
this.renderer.setElementAttribute(this.el.nativeElement, 'placeholder', s);
});
示例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!');
}