• 카테고리

    질문 & 답변
  • 세부 분야

    프론트엔드

  • 해결 여부

    미해결

클래스 수업 내용 중 오류 질문

22.02.06 22:41 작성 조회수 411

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.
빠른 수정을 사용할 수 없음
 
 
 
 

답변 3

·

답변을 작성해보세요.

0

고가영님의 프로필

고가영

2022.07.08

ItemComponent 내의 item 변수 가시성을 private으로 하면 오류가 납니다. private을 지우니 오류가 안나네요. 찾아보니 template 즉 html에서는 private으로 선언된 변수 사용이 안되는 듯 합니다.

참고 링크: https://github.com/angular/angular-cli/issues/17395

0

전재홍님의 프로필

전재홍

2022.06.19

저도 같은 오류가 나와서 그런데 혹시 오류 해결을 하셨나여?

0

강선모님의 프로필

강선모

2022.04.14

혹시 이거 해결하셧나요?