简体   繁体   中英

Angular 4 NG Build --Prod error with dialogs

I'm getting the following errors while trying to run NG Build --Prod (for AoT compiling of course)

ERROR in ng:///C:/Users/DTurcich/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/add.notification.one.dialog.component.html (7,96): Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.

ERROR in ng:///C:/Users/DTurcich/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/add.notification.one.dialog.component.html (7,138): Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.

ERROR in ng:///C:/Users/DTurcich/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/add.notification.one.dialog.component.html (13,47): Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.

ERROR in ng:///C:/Users/DTurcich/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/add.notification.one.dialog.component.html (7,4): Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.

ERROR in ng:///C:/Users/DTurcich/DashboardConsole/ASCI.DashboardConsole.Frontend/src/app/add.notification.one.dialog.component.html (6,3): Property 'newAdmin' does not exist on type 'AddNotificationOneDialog'.

These errors are only being thrown when attempting to do NG Build --Prod. non --Prod builds are being completed successfully, I know that AoT compiling does things differently but I'm unsure what I need to do to remedy the situation because what I have looked up hasn't seemed to help.

Pertinent Files:

Angular 4 Typescript:

@Component({
    selector: 'add-notification-one-dialog',
    templateUrl: './add.notification.one.dialog.component.html',
    styleUrls: ['./dialog.component.css']
})
export class AddNotificationOneDialog {
    constructor(
        public dialogRef: MdDialogRef<AddNotificationOneDialog>,
        private snackBar: MdSnackBar

    ) { }

    // opens a dialog to warn the user they didn't input correctly
    openSnackBar(message) {
        this.snackBar.open(message, "Close", { duration: 3000 });
    }

    // function called on press of the submit button which checks regular expression compliance 
    pressSubmit(newAdmin: any): void {
        var regEx = new RegExp("[^a-zA-z0-9]");
        var testedInput = regEx.test(newAdmin);

        if (testedInput !== true) {
            this.dialogRef.close(newAdmin)
        }
        else {
            this.openSnackBar("Please enter only A-Z and 0-9");
        }
    }
}

HTML:

<div class="dialog-box">
    <h1 md-dialog-title>Add a new Administrator?</h1>

    <md-dialog-content>
        <md-input-container>
            <input mdInput class="text-input" pattern="[A-Za-z0-9 ]+" placeholder="Name" maxlength="30" [(ngModel)]="newAdmin" [value]="newAdmin" (keyup.enter)="pressSubmit(newAdmin)">
        </md-input-container>
    </md-dialog-content>

    <md-dialog-actions>
        <div class="button-container">
            <button class="pull-left" md-raised-button (click)="pressSubmit(newAdmin)">Submit</button>
            <button class="pull-right" md-raised-button (click)="dialogRef.close('Cancel')">Cancel</button>
        </div>
    </md-dialog-actions>
</div>

Thank you in advance!

You forgot to declare your newAdmin variable:

export class AddNotificationOneDialog {

  public newAdmin: any;

  constructor(...){ }
  ...
}

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