我ERROR DOMException [InvalidCharacterError: "String contains an invalid character"
code: 5
nsresult: 0x80530005
location: http://localhost:4200/vendor.bundle.js:67608]
在尝试使用自定义属性指令编译 Angular 组件时得到。我的 AppComponent、指令和基本模板的代码如下:
leftAlign.directive.ts
import {
Directive,
HostListener,
HostBinding,
Input,
Output,
ElementRef,
Renderer2 // for host class binding
} from '@angular/core';
@Directive({
selector: '[leftAlign]'
})
export class LeftAlignDirective {
public constructor(
private el: ElementRef,
private renderer: Renderer2
) {
this.renderer.addClass(this.el.nativeElement, 'ui leftAlign');
}
}
app.component.ts
import { Component } from '@angular/core';
import { LeftAlignDirective } from './Directives/left-align.directive';
@Component({
selector: `app-root`,
templateUrl: './app.component.html'
})
export class AppComponent {
public static SemanticUiBaseDir = '../../semantic/dist/';
public getSemanticeUiBaseDir() : string{
return AppComponent.SemanticUiBaseDir;
}
public constructor() {}
}
app.component.html
!--
@ semantic-ui.min.css
-->
<link rel="stylesheet" type="text/css" href="/home/zerocool/km-live/FrontEndComponent/semantic/dist/semantic.css">
<!--
@ @semantic.min.js
-->
<script src="./home/zerocool/km-live/FrontEndComponent/semantic/semantic.js"></script>
<p leftAlign>This should be aligned left!</p>
我有兴趣了解以下内容: 1. 导致此类错误的原因是什么?2. 本案例中的错误是什么原因造成的?
谢谢