最佳答案
在添加了一些新的 html 代码之后,我在角度4中得到了一个错误,之前的表单工作得很好。我尝试注释新的代码,但它仍然不工作-该怎么办-我研究了这个错误,尝试解决,但没有任何帮助-也没有我得到问题的确切位置
我的准则:
<form role="form" #adminForm="ngForm" (ngSubmit)="logAdmin(adminForm.form)">
<div class="form-group">
<input class="form-control" [(ngModel)]="adminUsername" #adminUsername="ngModel" placeholder="Username" type="text" name="adminUsername"
required>
<div *ngIf="adminUsername.touched && adminUsername.errors">
<div class="alert alert-danger" *ngIf="adminUsername.errors.required">Username is required</div>
</div>
</div>
<div class="form-group">
<input class="form-control" [(ngModel)]="passwordText" #adminPassword="ngModel" id="adminPassword" name="adminPassword" placeholder="Password"
type="password" required>
</div>
<div class="alert alert-danger" *ngIf="adminPassword.touched && adminPassword.errors">Password is required</div>
<div class="col-md-6" style="text-align: right">
<button type="submit" class="btn-yellow" [disabled]="!adminForm.valid">Log In</button>
</div>
</form>
我得到的错误是:
Error: Cannot assign to a reference or variable!
at _AstToIrVisitor.visitPropertyWrite (webpack-internal:///../../../compiler/esm5/compiler.js:26550:23)
at PropertyWrite.visit (webpack-internal:///../../../compiler/esm5/compiler.js:4895:24)
at convertActionBinding (webpack-internal:///../../../compiler/esm5/compiler.js:26000:45)
at eval (webpack-internal:///../../../compiler/esm5/compiler.js:28519:22)
at Array.forEach (<anonymous>)
at ViewBuilder._createElementHandleEventFn (webpack-internal:///../../../compiler/esm5/compiler.js:28515:18)
at nodes.(anonymous function) (webpack-internal:///../../../compiler/esm5/compiler.js:27934:27)
at eval (webpack-internal:///../../../compiler/esm5/compiler.js:28460:22)
at Array.map (<anonymous>)
at ViewBuilder._createNodeExpressions (webpack-internal:///../../../compiler/esm5/compiler.js:28459:56)
at _AstToIrVisitor.visitPropertyWrite (webpack-internal:///../../../compiler/esm5/compiler.js:26550:23)
at PropertyWrite.visit (webpack-internal:///../../../compiler/esm5/compiler.js:4895:24)
at convertActionBinding (webpack-internal:///../../../compiler/esm5/compiler.js:26000:45)
at eval (webpack-internal:///../../../compiler/esm5/compiler.js:28519:22)
at Array.forEach (<anonymous>)
at ViewBuilder._createElementHandleEventFn (webpack-internal:///../../../compiler/esm5/compiler.js:28515:18)
at nodes.(anonymous function) (webpack-internal:///../../../compiler/esm5/compiler.js:27934:27)
at eval (webpack-internal:///../../../compiler/esm5/compiler.js:28460:22)
at Array.map (<anonymous>)
at ViewBuilder._createNodeExpressions (webpack-internal:///../../../compiler/esm5/compiler.js:28459:56)
at resolvePromise (webpack-internal:///../../../../zone.js/dist/zone.js:824:31)
at resolvePromise (webpack-internal:///../../../../zone.js/dist/zone.js:795:17)
at eval (webpack-internal:///../../../../zone.js/dist/zone.js:873:17)
at ZoneDelegate.invokeTask (webpack-internal:///../../../../zone.js/dist/zone.js:425:31)
at Object.onInvokeTask (webpack-internal:///../../../core/esm5/core.js:4944:33)
at ZoneDelegate.invokeTask (webpack-internal:///../../../../zone.js/dist/zone.js:424:36)
at Zone.runTask (webpack-internal:///../../../../zone.js/dist/zone.js:192:47)
at drainMicroTaskQueue (webpack-internal:///../../../../zone.js/dist/zone.js:602:35)
at <anonymous>
我在互联网上搜索,发现问题和答案相同的错误-但我没有得到任何解决方案,为我工作... 这就是为什么这个错误可能会重复,但答案似乎是不同的,然后有许多。