感谢您阅读我的问题。现在,我是在 Angular CLI 中构建的应用程序。这是我的 package.json:
{
"@angular/animations": "^5.0.0",
"@angular/cdk": "^5.0.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/compiler-cli": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/flex-layout": "*",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/material": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/platform-server": "^4.4.4",
"@angular/router": "^5.0.0",
"angular-in-memory-web-api": "~0.3.0",
"angular2-json-schema-form": "*",
"angular2-toaster": "*",
"core-js": "^2.4.1",
"ng2-responsive": "*",
"rxjs": "^5.5.2",
"socket.io-client": "^1.3.0",
"systemjs": "0.19.40",
"traceur": "*",
"zone.js": "^0.8.14"
}
在我的应用程序中,我有一些选择标签,例如:
<div class="tab-pane fade" id="v-pills-auto" role="tabpanel" aria-labelledby="v-pills-auto-tab">
<div class="row justify-content-center">
<div class="mb-2 schema-form-div list-group-item form-group col-md-12" *ngFor="let choice of autoRestartScheduleField; let idx = index;">
<div class="row">
<label for="cluster" class="m-auto col-md-1">Cluster </label>
<select class="p-0 m-auto col-md-4 form-control" name="cluster" id="cluster" [(ngModel)]="autoRestartScheduleField[idx].cluster" (change)="onSelectClusterChange(idx)">
<option *ngFor="let cls of listClusterCanChoice" value="{{cls.cluster}}" [disabled]="cls.hide">{{cls.cluster}}</option>
</select>
<label for="timer" class="m-auto col-md-1">Timer </label>
<input class="m-auto col-md-1 form-control" name="timer" id="timer" [(ngModel)]="autoRestartScheduleField[idx].timer" type="number">
<label for="type" class="m-auto col-md-1">Type </label>
<select class="p-0 m-auto col-md-2 form-control" name="type" id="type" [(ngModel)]="autoRestartScheduleField[idx].type">
<option class="mat-select" value="hour">hour</option>
<option class="mat-select" value="day">day</option>
<option class="mat-select" value="week">week</option>
</select>
<button class="mr-3 col-md-1 btn btn-warning" (click)="removeField(idx)">Delete</button>
</div>
</div>
<div class="row">
<button class="btn btn-secondary" (click)="addNewField()">New</button>
<button class="ml-3 btn btn-primary" (click)="autoRestartOnSubmit()">Save!</button>
</div>
</div>
</div>
当我选择某个值时,我使用双向绑定和(更改)处理程序事件。所以,当我用“ng server”运行它时,我的应用程序是这样的(这是我想要的结果): 用“ng serve”版本运行我的应用程序
但是,当我使用 cammand "ng build --prod --aot" 构建应用程序时,然后我在 express 服务器上运行它,我收到结果(我不知道为什么会这样???): 运行我的应用程序ng build --prod --aot" 版本
但是,我在没有 opts 的情况下使用命令“ng build”再次构建并在我的 express 服务器上运行它,我收到的结果就像我运行“ng serve”时一样。 使用“ng build”运行我的应用程序而不使用 opts
我不明白为什么会这样。我想我在运行“ng build --prod --oat”时破坏了一些东西,但我没有收到任何警告或错误。
再次感谢,新年快乐!