오류: 참조 또는 변수에 할당할 수 없습니다!앵귤러 4
새로운 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>
인터넷에서 검색해보니 같은 오류에 대한 질문과 답변이 있었습니다. 하지만 저는 저에게 맞는 해결책을 찾지 못했습니다.그렇기 때문에 이 오류가 반복될 수 있지만 정답은 다른 많은 사람들과 다른 것 같습니다.
문제는 제가 ngModel 변수 이름을 정확히 똑같이 바꿨다는 것입니다.
[(ngModel)]="adminUsername" #adminUsername="ngModel"
나에게 효과적인 솔루션
[(ngModel)]="adminUsernameText" #adminUsername="ngModel"
언급URL : https://stackoverflow.com/questions/48021581/error-cannot-assign-to-a-reference-or-variable-angular-4
'programing' 카테고리의 다른 글
좋은 속도 제한 알고리즘은 무엇입니까? (0) | 2023.06.09 |
---|---|
vuex 스토어 토큰이 구성 요소 간에 업데이트되지 않음 (0) | 2023.06.09 |
동적으로 작성된 단추에 코드 할당 (0) | 2023.06.09 |
NLog 메시지를 Visual Studio의 출력 창으로 출력하려면 어떻게 해야 합니까? (0) | 2023.06.09 |
Wordpress 무한 스크롤로 제품을 로드한 후 Woocommerce 스크립트를 다시 초기화합니다. (0) | 2023.06.09 |