2
這是我的代碼,但我得到undefined
錯誤:無法通過查看孩子訪問進口組合在Angular2-RC4
import {IONIC_DIRECTIVES} from 'ionic-angular'
@Component({
selector: 'personal-info',
templateUrl: 'build/pages/transaction/personal-info/personal-info.html',
directives: [IONIC_DIRECTIVES]
})
export class PersonalInfoPage {
infoForm: ControlGroup
constructor (
private formBuilder: FormBuilder,
) {
this.infoForm = formBuilder.group({//...})
})
}
import {PersonalInfoPage} from './personal-info/personal-info'
@Component({
templateUrl: 'build/pages/transaction/transaction.html',
directives: [PersonalInfoPage,PaymentDetailsPage,AddressPage,IdentityPage],
})
export class TransactionPage implements AfterViewInit {
@ViewChild('PersonalInfoPage') personalInfo: PersonalInfoPage
@ViewChild('PaymentDetailsPage') paymentDetails: PaymentDetailsPage
@ViewChild('AddressPage') address: AddressPage
@ViewChild('IdentityPage') identityPage: IdentityPage
constructor(
) {}
ngAfterViewInit() {
console.log(this.personalInfo.infoForm.valid);
}
錯誤在瀏覽器中:
EXCEPTION: Error: Uncaught (in promise): EXCEPTION: Error in ./TransactionPage class TransactionPage_Host - inline template:0:0 ORIGINAL EXCEPTION: TypeError: Cannot read property 'infoForm' of undefined
任何想法我我錯過了?
找到你的答案前2分鐘。 30分鐘的調試。哦,歡樂...... – nottinhill
他們微妙的差異... –