2017-11-21 1 views
0

このエラーを修正する方法を理解していないか、またはわかっていません。角誤差:代入式の左辺は、変数またはプロパティのアクセスでなければなりません。

これはコードです。それは私が思うpushItem関数と関係があると思われる。

> **app.component.ts** 
 

 
import { Component, NgModule } from '@angular/core'; 
 

 
@Component({ 
 
    selector: 'app-root', 
 
    templateUrl: './app.component.html', 
 
    styleUrls: ['./app.component.css'] 
 
}) 
 
export class AppComponent { 
 
    //bind this array to li in html 
 
    items = ['Sistema', 'Playstation', 'Web']; 
 

 
    newItem = ''; 
 

 
    pushItem = function() { 
 
    if(this.newItem ! = ''){ 
 
     this.items.push(this.newItem); 
 
     this.newItem = ''; 
 
    } 
 
    } 
 

 

 
}
@import '~font-awesome/css/font-awesome.css'; 
 

 
.main{ 
 
    width: 500px; 
 
    text-align: center; 
 
    margin: 0 auto; 
 
    border: 2px solid #d7d7d7; 
 
    border-bottom: 0px; 
 
    margin-top: 20px; 
 
    font-family: sans-serif; 
 
} 
 

 
h1{ 
 
    text-align: center; 
 
    background-color: #5c8297; 
 
    padding: 30px 0px; 
 
    margin-top: 0px; 
 
    color: #f7f7f7; 
 
} 
 

 
.addItem{ 
 
    position: relative; 
 
    padding-bottom: 0px; 
 
    height: 30px; 
 
} 
 

 
.addText{ 
 
    width: 80%; 
 
    height: 30px; 
 
    padding: 5px; 
 
    font-size: 20px; 
 
} 
 

 
button{ 
 
    height: 45px; 
 
    width: 50px; 
 
    padding: 5px; 
 
} 
 

 
ul{ 
 
    list-style: none; 
 
    font-size: 20px; 
 
    color: #686868; 
 
    margin-left: -40px; 
 
    margin-bottom: 0px; 
 
} 
 

 
li{ 
 
    border-bottom: 1px solid #bfbfbf; 
 
    background: #d7d7d7; 
 
    padding: 10px 0px; 
 
    margin-bottom: 5px; 
 
} 
 

 
span{ 
 
    cursor: pointer; 
 
    position: relative; 
 
    float: right; 
 
    margin-right: 15px; 
 
}
> **app.component.html** 
 

 
<div class = 'main'> 
 
    <h1>Item List</h1> 
 
    <div class = 'add'> 
 
    <input [(ngModel)] = 'newItem' placeholder="add item" class = 'addText'> 
 
    <button>Add</button> 
 
    </div> 
 
    <ul> 
 
    <Li *ngFor = 'let i of items'> 
 
     {{i}} 
 
     <span><i class="fa fa-times" aria-hidden="true"></i></span> 
 
    </Li> 
 
    </ul> 
 
</div>

Error nessage

答えて

2

私はあなたが

if(this.newItem != ''){ 
によって

if(this.newItem ! = ''){ 

を交換すべきだと思う

間にスペースがあります! =

関連する問題