简体   繁体   中英

Angular build prod error “Property is private and only accessible”

While I am trying to do build --prod from my page I was getting few error this error where bit confusing.

For example:

Property 'selectedSize' is private and only accessible within class 'EditorComponent'.

<select id="dimension-preset" class="form-control" [(ngModel)]="selectedSize">

Property 'size' is private and only accessible within class 'EditorComponent'.

<input type="number" class="form-control" [(ngModel)]="size.width" (keyup)="changeSize()"/>

How can I solve this?

This is my html:

  <select id="dimension-preset" class="form-control" [(ngModel)]="selectedSize"
      (ngModelChange)="changeToPreset($event)">
       <option value="null">Requirements</option>
          <option *ngFor="let s of sizes" [ngValue]="s">{{s.width}}x{{s.height}}</option>
  </select>

This is my html for size

     <input type="number" class="form-control" [(ngModel)]="size.width" (keyup)="changeSize()"/>
     <span class="input-group-addon" id="sizing-addon1"><i class="fa fa-arrows-h" aria-hidden="true"></i></span>

This is my TS:

private selectedSize: any = null;

    private size: any = {
        width: 1024,
        height: 768
  };

you have two ways to fix

  1. Remove private on your.ts file or
  2. Or you can change private to public, I would prefer first one because its more clear

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM