I'm sending values from the HTML page into TS component without using form, I got an a build error when I try npm run build, here is my sample:
I have no problem using >npm run dev or >ng build But when I build it for production, it will through an error using
npm run build
src\\app\\messages\\messages-new\\messages-new.component.html(52,22): : Property 'messageTitle' does not exist on type 'MessagesNewComponent'.
HTML:
<input matInput placeholder="Type a title" name="messageTitle" [(ngModel)]="messageTitle">
<button class="simple-form-button" color="primary" mat-raised-button type="submit" value="submit" (click)="sendMessage(messageTitle)">
<mat-icon>send</mat-icon> Send
</button>
这意味着您需要在 component.ts 中声明变量
messageTitle : string;
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.