繁体   English   中英

带有对话框的Angular 4 NG Build --Prod错误

[英]Angular 4 NG Build --Prod error with dialogs

尝试运行NG Build --Prod时出现以下错误(当然是AoT编译)

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'.

仅在尝试执行NG Build --Prod时抛出这些错误。 非--Prod版本已成功完成,我知道AoT编译的功能有所不同,但是我不确定需要采取什么措施来纠正这种情况,因为我查找的内容似乎无济于事。

相关文件:

Angular 4打字稿:

@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>

先感谢您!

您忘记声明了newAdmin变量:

export class AddNotificationOneDialog {

  public newAdmin: any;

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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