Hamid Aijaz
Hamid Aijaz

Reputation: 47

DOMException: String contains an invalid character

When I add [(ngModel)] in code I get this error:

DOMException: String contains an invalid character

The component file:

const keyInput = document.createElement('input');
keyInput.setAttribute('class', 'form-control input-transparent');
keyInput.setAttribute('type', 'text');
keyInput.setAttribute('[(ngModel)]', trans.key);
keyInput.setAttribute('name', 'keys[]');
keyInput.setAttribute('value', trans.key);

Can anyone help me with this issue?

Upvotes: 2

Views: 7030

Answers (2)

Eljah
Eljah

Reputation: 5165

in my case I have fount the typo in my template like this: <div class="alert alert-danger" *ngIf="errorTimeNotAvailable" jhiTranslate="businesslogic.create.kindergartenclass.timenotavailable" [translateValues]="{ entityName: this.concurrentExisitngKindergartenClass }" ]> with extra ]

everything compiled well, but failed at the runtime

Upvotes: 3

Nitishkumar Singh
Nitishkumar Singh

Reputation: 1839

I would suggest to use Dynamic form feature already available in Angular. It provides a lot of control on form controls as well as a systematic approach too. Please follow the link, for more details

Upvotes: 0

Related Questions