我正在尝试为生产构建我的应用程序,在解决所有错误后,有一个我似乎无法弄清楚的错误。
运行ng build --prod时,会发生以下错误:
D中的错误:/1.Work/2.Projects/Application/Quintiles/IHRegistery/4.UI/iHreg/src / $$ _ gendir / app / pages / visit / component / visitInfo / visitInfo.component.ngfactory。 ts(3860,30):物业'访问'是n ot存在于'VisitInfoComponent'类型上。
这是我的访问组件:
import { Component, Input, OnChanges, OnInit } from '@angular/core';
import { Visit } from '../../../../model/Visit';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { VisitService } from '../../visit.service';
import { Router } from '@angular/router';
import { APIConstants } from '../../../../helpers/Constants/const-apis';
import { Message } from '../../../../model/Message';
@Component( {
selector: 'cmp-visit-info',
templateUrl: 'visitInfo.html',
styleUrls: ['visitInfo.scss'],
} )
export class VisitInfoComponent implements OnInit, OnChanges {
@Input( 'visitItem' ) visitItem: Visit;
visitObj: Visit;
myForm: FormGroup;
// itemObj: Visit;
createObj: boolean = true;
message: Message = new Message();
constructor( private visitService: VisitService,
private apiConst: APIConstants,
private route: Router,
private fb: FormBuilder ) {
this.visitObj = new Visit();
}
buildForm(): void {
this.myForm = this.fb.group( {
visitDate: [null, Validators.required],
weight: [null, Validators.required],
height: [null, Validators.required],
lowPressure: [null],
highPressure: [null],
heartRate: [null],
temp: [null],
surg: [null],
dent: [null],
phys: [null],
ortha: [null],
labAss: [null],
imag: [null],
trans: [null],
treat: [null],
lastComp: [null],
} );
this.myForm.valueChanges
.subscribe( data => this.onValueChanged( data ) );
this.onValueChanged(); // (re)set validation messages now*/
}
onValueChanged( data?: any ) {
if ( !this.myForm ) {
return;
}
const form = this.myForm;
for ( const field in this.formErrors ) {
// clear previous error message (if any)
this.formErrors[field] = '';
const control = form.get( field );
if ( control && control.dirty && !control.valid ) {
const messages = this.validationMessages[field];
for ( const key in control.errors ) {
this.formErrors[field] += messages[key] + ' ';
}
}
}
}
ngOnInit() {
this.buildForm();
/*this.itemObj = this.router.params.subscribe(params => {
this.itemObj = params; // (+) converts string 'id' to a number
console.log('params',this.itemObj);
if(this.itemObj.id){
this.createObj=false;
this.visitObj = this.itemObj;
/!*this.visitObj.id=this.itemObj.id;
this.visitObj.visitDate=this.itemObj.visitDate;
this.visitObj.bloodPressureHigh=this.itemObj.bloodPressureHigh;
this.visitObj.bloodPressureLow=this.itemObj.bloodPressureLow;
this.visitObj.dentalProcedures=this.itemObj.dentalProcedures;
this.visitObj.complicationLastVisit=this.itemObj.complicationLastVisit;
this.visitObj.heartRate=this.itemObj.heartRate;
this.visitObj.height=this.itemObj.height;
this.visitObj.weight=this.itemObj.weight;
this.visitObj.userId=this.itemObj.userId;
this.visitObj.imagingProcedures=this.itemObj.imagingProcedures;
this.visitObj.labAssessmentsProcedures=this.itemObj.labAssessmentsProcedures;
this.visitObj.orthopedicProcedures=this.itemObj.orthopedicProcedures;
this.visitObj.patientId=this.itemObj.patientId;
this.visitObj.physiotherapyProcedures=this.itemObj.physiotherapyProcedures;
this.visitObj.temperature=this.itemObj.temperature;
this.visitObj.transfusionLastVisit=this.itemObj.transfusionLastVisit;
this.visitObj.surgicalOperationProcedures=this.itemObj.surgicalOperationProcedures;
this.visitObj.treatmentLastVisit=this.itemObj.treatmentLastVisit;*!/
}else {
console.log('No params');
}
});*/
}
ngOnChanges() {
console.log( 'visit-info', this.visitItem );
// console.log('visit-info is empty', this.helper.isEmpty(this.visitItem));
if ( this.visitItem !== undefined ) {
this.visitObj = this.visitItem;
this.createObj = false;
} else {
this.createObj = true;
}
}
submitVisit() {
console.log( 'submit' );
if ( this.createObj ) {
this.createVisit();
} else {
this.updateVisit();
}
}
createVisit(resolve?, reject?) {
this.visitObj.userId = this.apiConst.getLocalStorageData( this.apiConst.LSUSERID );
this.visitObj.patientId = this.apiConst.getLocalStorageData( this.apiConst.LSPATIENTID );
console.log( 'create Obj', this.visitObj );
this.visitService.createPatientVisit( this.visitObj ).subscribe( res => {
if ( res.success && res.returnObject !== null ) {
this.message.type = 'success';
this.message.body = 'Visit Create Successfully';
window.location.reload();
if ( resolve ) {
resolve( true );
}
}
}, err => {
console.log( err );
this.message.type = 'danger';
this.message.body = 'Visit Creation failed, please try again later.';
if ( reject ) {
reject( false );
}
} );
}
updateVisit(resolve?, reject?) {
console.log( 'update Obj', this.visitObj );
this.visitService.updatePatientVisit( this.visitObj, this.visitObj.id ).subscribe( res => {
console.log( 'res-obj-updated', res );
if ( res.success ) {
this.message.type = 'success';
this.message.body = 'Visit update Successfully';
window.location.reload();
if ( resolve ) {
resolve( true );
}
}
}, err => {
console.log( err );
this.message.type = 'danger';
this.message.body = 'Updating the visit failed, please try again.';
if ( reject ) {
reject( false );
}
} );
}
saveBeforeNavigation(): Promise<boolean> {
return new Promise( ( resolve, reject ) => {
if ( this.createObj ) {
this.createVisit(resolve, reject);
} else {
this.updateVisit(resolve, reject);
}
} );
}
formErrors = {
visitDate: '',
weight: '',
height: '',
lowPressure: '',
highPressure: '',
heartRate: '',
temp: '',
surg: '',
dent: '',
phys: '',
ortha: '',
labAss: '',
imag: '',
trans: '',
treat: '',
lastComp: '',
};
validationMessages = {
visitDate: {
'required': 'Regimen Date is required.',
},
weight: {
'required': ' Type is required.',
},
height: {
'required': ' Drug Name is required.',
},
lowPressure: {},
highPressure: {},
heartRate: {},
temp: {},
surg: {},
dent: {},
phys: {},
ortha: {},
labAss: {},
imag: {},
trans: {},
treat: {},
lastComp: {},
};
beforeSaveValidation( url ) {
let confirm = window.confirm( 'Save changes?' );
if ( confirm ) {
this.saveBeforeNavigation().then( whenResolve => {
this.route.navigate( [url] );
}, whenReject => {
alert( 'couldn\'t save the data. Server error occurred' );
} );
}
}
}
我的angular-cli版本是:1.0.4
修改
这是visitInfo模板:
<ba-card [title]="Visit" baCardClass="with-scroll">
<div class="widgets">
<form (ngSubmit)="submitVisit()" [formGroup]="myForm">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="form-group col-3">
<label class="control-label">Date Of Visit</label>
<input type="date" class="form-control col-9" [(ngModel)]="visitObj.visitDate"
formControlName="visitDate" id="visitDate">
</div>
</div>
<ba-card title="Vital Signs" baCardClass="with-scroll">
<div id="profile">
<div class="row">
<div class="form-group col-2">
<label class="control-label">Weight (KG)</label>
<input type="number" class="form-control col-6" [(ngModel)]="visitObj.weight" formControlName="weight" id="weight">
<div *ngIf="formErrors.weight" class="col-3 alert alert-danger">
{{ formErrors.weight }}
</div>
</div>
<div class="form-group col-2">
<label class="control-label">Height (cm)</label>
<input type="number" class="form-control col-6" [(ngModel)]="visitObj.height" formControlName="height" id="height">
<div *ngIf="formErrors.height" class="col-3 alert alert-danger">
{{ formErrors.height }}
</div>
</div>
<div class="form-group col-3">
<label>Blood Pressure (mmHg)</label>
<div class="row">
<div class="col-5">
<input type="number" class="form-control" [(ngModel)]="visitObj.bloodPressureHigh" formControlName="highPressure" id="highPressure">
<div *ngIf="formErrors.highPressure" class="col-3 alert alert-danger">
{{ formErrors.highPressure }}
</div>
</div>
<div class="col-1 text-center"><span class="h3">/</span></div>
<div class="col-5">
<input type="number" class="form-control" [(ngModel)]="visitObj.bloodPressureLow" formControlName="lowPressure" id="lowPressure">
<div *ngIf="formErrors.lowPressure" class="col-3 alert alert-danger">
{{ formErrors.lowPressure }}
</div>
</div>
</div>
</div>
<div class="form-group col-2">
<label>Heart Rate (bpm)</label>
<input type="number" class="form-control col-6" [(ngModel)]="visitObj.heartRate" formControlName="heartRate" id="heartRate">
<div *ngIf="formErrors.heartRate" class="col-3 alert alert-danger">
{{ formErrors.heartRate }}
</div>
</div>
<div class="form-group col-2">
<label>Temperature (°C)</label>
<input type="number" class="form-control col-6" [(ngModel)]="visitObj.temperature" formControlName="temp" id="temp">
<div *ngIf="formErrors.temp" class="col-3 alert alert-danger">
{{ formErrors.temp }}
</div>
</div>
</div>
</div>
</ba-card>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div>
<ba-card title="Did the patient undergo any of the following since last visit?" baCardClass="with-scroll">
<div class="form-group row">
<div class="col-6">
<div class="checkbox">
<ba-checkbox [(ngModel)]="visitObj.surgicalOperationProcedures" [label]="'Surgical/operation procedures'"
[ngModelOptions]="{standalone: true}"></ba-checkbox>
</div>
<div class="checkbox">
<ba-checkbox [(ngModel)]="visitObj.dentalProcedures" [label]="'Dental procedures'"
[ngModelOptions]="{standalone: true}"> </ba-checkbox>
</div>
<div class="checkbox">
<ba-checkbox [(ngModel)]="visitObj.physiotherapyProcedures" [label]="'Physiotherapy'"
[ngModelOptions]="{standalone: true}"></ba-checkbox>
</div>
<div class="checkbox">
<ba-checkbox [(ngModel)]="visitObj.orthopedicProcedures" [label]="'Orthopedic procedures'"
[ngModelOptions]="{standalone: true}"></ba-checkbox>
</div>
<div class="form-group"
*ngIf="visitObj.surgicalOperationProcedures || visitObj.dentalProcedures || visitObj.physiotherapyProcedures || visitObj.orthopedicProcedures">
<a class="btn btn-primary" (click)="beforeSaveValidation('/pages/patient/patientInfo/intervention')">Edit</a>
</div>
</div>
<div class="col-6">
<div class="form-group row">
<div class="checkbox col-6">
<ba-checkbox [(ngModel)]="visitObj.labAssessmentsProcedures" [label]="'Lab assessments'"
[ngModelOptions]="{standalone: true}"></ba-checkbox>
</div>
<div class="col-6">
<div *ngIf="visitObj.labAssessmentsProcedures">
<span class=" edit-btn">
<a class="btn btn-primary" (click)="beforeSaveValidation('/pages/patient/patientInfo/labAssessments')"> Edit </a>
</span>
</div>
</div>
<div class="col-6">
<div class="checkbox">
<ba-checkbox [(ngModel)]="visitObj.imagingProcedures" [label]="'Imaging procedures'"
[ngModelOptions]="{standalone: true}"></ba-checkbox>
</div>
</div>
<div class="col-6">
<div *ngIf="visitObj.imagingProcedures">
<span class=" edit-btn">
<a class="btn btn-primary" (click)="beforeSaveValidation('/pages/patient/patientInfo/imaging')"> Edit </a>
</span>
</div>
</div>
</div>
</div>
</div>
</ba-card>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div>
<ba-card title="Since last visit, did the patient receive any of the following:" baCardClass="with-scroll">
<div class="form-group">
<div class="row">
<div class="col-md-6">
<div class="checkbox">
<ba-checkbox [(ngModel)]="visitObj.transfusionLastVisit" [label]="'Transfusions'"
[ngModelOptions]="{standalone: true}"></ba-checkbox>
</div>
</div>
<div class="col-md-6">
<div *ngIf="visitObj.transfusionLastVisit">
<span class=" edit-btn">
<a class="btn btn-primary" (click)="beforeSaveValidation('/pages/patient/patientInfo/transfusion')"> Edit </a>
</span>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="checkbox">
<ba-checkbox [(ngModel)]="visitObj.treatmentLastVisit" [label]="'Treatment (New/Modified)'"
[ngModelOptions]="{standalone: true}"></ba-checkbox>
</div>
</div>
<div class="col-md-6">
<div *ngIf="visitObj.treatmentLastVisit">
<span class=" edit-btn">
<a class="btn btn-primary" (click)="beforeSaveValidation('/pages/patient/patientInfo/treatment')"> Edit </a>
</span>
</div>
</div>
</div>
</div>
</ba-card>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div>
<ba-card title="Since last visit, did the patient suffer from new complications/Adverse events?"
baCardClass="with-scroll">
<div class="form-group">
<div class="input-demo radio-demo row">
<div class="col-md-2">
<label class="radio-inline custom-radio nowrap">
<input type="radio" [(ngModel)]="visitObj.complicationLastVisit" [value]="1"
formControlName="lastComp" >
<span>Yes</span>
</label>
</div>
<div class="col-md-2">
<label class="radio-inline custom-radio nowrap">
<input type="radio" [(ngModel)]="visitObj.complicationLastVisit" [value]="2"
formControlName="lastComp" >
<span>No</span>
</label>
</div>
</div>
<div class="form-group" *ngIf="visitObj.complicationLastVisit == 1">
<a class="btn btn-primary" (click)="beforeSaveValidation('/pages/patient/patientInfo/complications')">Edit</a>
</div>
</div>
</ba-card>
</div>
</div>
</div>
<div class="row align-items-end">
<button type="submit" *ngIf="createObj" [disabled]="!myForm.valid" class="btn btn-block btn-primary">Save</button>
<button *ngIf="!createObj" [disabled]="!myForm.valid" class="btn btn-block btn-danger">Update</button>
</div>
</form>
</div>
<message-com [message]="message"></message-com>
</ba-card>
以下是使用的访问模型:
import * as models from './models';
export class Visit {
id?: number;
visitDate?: Date;
weight?: number;
height?: number;
bloodPressureLow?: number;
bloodPressureHigh?: number;
heartRate?: number;
temperature?: number;
surgicalOperationProcedures?: boolean;
dentalProcedures?: boolean;
physiotherapyProcedures?: boolean;
orthopedicProcedures?: boolean;
labAssessmentsProcedures?: boolean;
imagingProcedures?: boolean;
transfusionLastVisit?: boolean;
treatmentLastVisit?: boolean;
complicationLastVisit?: number;
patientId?: number;
userId?: number;
constructor() {
this.visitDate = new Date();
this.surgicalOperationProcedures = false;
this.dentalProcedures = false;
this.physiotherapyProcedures = false;
this.orthopedicProcedures = false;
this.labAssessmentsProcedures = false;
this.imagingProcedures = false;
this.transfusionLastVisit = false;
this.treatmentLastVisit = false;
}
}
答案 0 :(得分:0)
错误是由模板第一行中的title属性引起的
<ba-card [title]="Visit" baCardClass="with-scroll">
在这里,您告诉Angular搜索名为 Visit 的属性,但是VisitInfoComponent没有这样的属性,我想您可能希望标题为Visit,您有三个选项。
title="Visit"
或[title]="'Visit'"
或当你使用括号时,你告诉Angular将该属性绑定到变量,而不是纯文本。