2017-09-18 2 views
1
export interface Candidate { 
    name: string; 
    surname: string; 
    gender: boolean; 
    dateOfBirth: Date; 
    placeOfBirth: string; 
    originRegion: string; 
    originDivision: string; 
    originSubDivision: string; 
    employmentSituation: string; 
    typeHandicap: string; 
    nationality: string; 
    cardID: string; 
    cardIDIssueDate: string; 
    language1: string; 
    language2: string; 
    MaritalStatus: string; 
    numberOfChildren: number; 
    specialityDiploma: number; 
    seriesDiploma: string; 
    avgDiploma: string; 
    diplomaObtainYear: string; 
    degreeDiploma: string; 
    obtainingInstitution: string; 
    examCenter: string; 
    depositPlace: string; 
    optionOfTraining: string; 
    admissionMode: string; 
    cycle: string; 
    department: string; 
    option: string; 
    session: string; 
    residenceCity: string; 
    tel1: string; 
    tel2: string; 
    email: string; 
    bp: string; 
    fax: string; 
    address: string 
    practicedSport: string; 
    othersActivities: string; 
    dateFirstRegistration: Date; 
    dateModification: Date; 
    dateValidation: Date; 
    orderNumber: number; 
    dateForDeposit: number; 
    isValid: boolean; 
    periodModification: number; 
    //users_id; 
} 

registration.component.html 
<div class="innerElt"> 
        <input type="text" name="name" placeholder="name" [(ngModel)]="candidate.name" (click)="updatenameLabel('name')" (focusout)="updatenameLabel(''); updateprogressbar(1)" required > 
        </div> 
registration.component.ts 

import { Candidate } from "../candidate.interface"; 
export class RegistrationComponent implements OnInit { 
... 
candidate: Candidate; 

ngOnInit() {} 
... 
} 

Quand je lance cela, je l'ai toujours l'erreur:Interface angulaire 2 dans le modèle déposé accédant html donne toujours l'erreur

erreur TypeError: Impossible de lire le « nom » propriété de non définie à Object.View_RegistrationComponent_1.co [ comme updateDirectives] (RegistrationComponent.html: 23) à Object.debugUpdateDirectives [comme updateDirectives] (core.es5.js: 12806) à checkAndUpdateView (core.es5.js: 12144) à callViewAction (core.es5.js: 12507) à execEmbeddedViewsAction (core.es5.js: 12465) à checkAndUpdateView (core.es5.js: 12145) à callViewAction (core.es5.js: 12507) à execComponentViewsAction (core.es5.js: 12439) à checkAndUpdateView (core.es5.js: 12150) à callViewAction (core.es5.js: 12507)

+0

Toute idée? Merci ... –

+0

car la variable 'candidate' n'est jamais initialisée. 'candidat = {....}' vous aidera – Aravind

Répondre

0

Merci beaucoup Zissouu

Il fonctionne quand je fais quelque chose comme:

ngOnInit() { 
this.candidate = {name:"",surname:"",gender:false,dateOfBirth:new Date("February 4, 2016 10:13:00"),placeOfBirth:"",originRegion:"",originDivision:"",originSubDivision:"", 
        employmentSituation:"",typeHandicap:"",nationality:"",cardID:"",cardIDIssueDate:"",language1:"",language2:"",maritalStatus:"", 
        numberOfChildren:0,specialityDiploma:"",seriesDiploma:"",avgDiploma:"",diplomaObtainYear:"",degreeDiploma:"",obtainingInstitution:"", 
        examCenter:"",depositPlace:"",optionOfTraining:"",admissionMode:"",cycle:"",department:"",option:"",session:"",residenceCity:"",tel1:"",tel2:"", 
        email:"",bp:"",fax:"",address:"",practicedSport:"",othersActivities:"",dateFirstRegistration:new Date("February 4, 2016 10:13:00"),dateModification:new Date("February 4, 2016 10:13:00"),dateValidation:new Date("February 4, 2016 10:13:00"), 
        orderNumber:0,dateForDeposit:0,isValid:false,periodModification:0}; 
        ...}