Inflearn コミュニティ Q&A
클래스 수업 내용 중 오류 질문
作成
·
703
1
두가지 파일에서 오류가 있습니다.
참고로 하기 환경에서 작업을 하고 있습니다.
Angular CLI: 13.2.2
Node: 16.13.2
Package Manager: npm 8.1.2
OS: win32 x64
Angular: 13.2.1
클래스로 만든 Item.ts 클래스에서도 강사님하고 동일하게 작성하면 오류가 납니다.
export class Item {
id: String;
name: String ;
available: boolean ;
}
오류 내용:
속성 'id'은(는) 이니셜라이저가 없고 생성자에 할당되어 있지 않습니다.ts
name, available 다 동일한 오류가 뜹니다.
해결 방법이 있을까요?
item.component.html
<div>
<label>
<input [(ngModel)]="item.id" placeholder="ID"/>
</label>
</div>
<div>
<label>
<input [(ngModel)]="item.name" placeholder="Name"/>
</label>
</div>
<button (click)="saveItem()">Save</button>
ngModel = item.id /item.name 의 item에서 모두 오류가 납니다.
Property 'item' is private and only accessible within class 'ItemComponent'.ngtsc(2341)
item.component.ts(11, 4): Error occurs in the template of component ItemComponent.
Property 'item' is private and only accessible within class 'ItemComponent'.ngtsc(2341)
item.component.ts(11, 4): Error occurs in the template of component ItemComponent.
Angularjavascript
回答 3
0
ItemComponent 내의 item 변수 가시성을 private으로 하면 오류가 납니다. private을 지우니 오류가 안나네요. 찾아보니 template 즉 html에서는 private으로 선언된 변수 사용이 안되는 듯 합니다.
참고 링크: https://github.com/angular/angular-cli/issues/17395
0
0





