2017-12-29 15 views
0

新しいHTMLコードを追加した後、角度4でエラーが発生しています。以前はフォームが正常に動作していました。私はこのエラーを調査し、解決を試みたが、何も助けない - - 何をすべきか - 私は、コードが、そのまだイマイチの作業新しいをコメントしようとしたも私は問題の正確な位置にエラー:参照または変数に割り当てることができません! Angular 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> 

私は、インターネット上で検索し、質問が同じエラーのために答える&た - しかし、私は私のために働いていたすべてのソリューションを持ってdidntの...ザッツこのエラーが繰り返されるかもしれない理由が、答えが見えるそこから多くの異なるものになります。

+0

Q&Aを歓迎していますが、最初に検索することを確認し、他がありますされている私のために働いたソリューションこれに関する質問と回答;) – Alex

答えて

5

問題は、私がngModel変数名に改名したことで、全く同じ

[(ngModel)]="adminUsername" #adminUsername="ngModel" 

[(ngModel)]="adminUsernameText" #adminUsername="ngModel" 
関連する問題