Problem in ngmodel

if i write [(ngModel)] i got below error

browser_adapter.js:84 Error: No value accessor for ''
at new BaseException (exceptions.js:27)
at _throwError (shared.js:55)
at Object.setUpControl (shared.js:30)
at NgModel.ngOnChanges (ng_model.js:41)
at AppView._View_LoginPage0.detectChangesInternal (LoginPage.template.js:374)
at AppView.detectChanges (view.js:243)
at AppView.detectViewChildrenChanges (view.js:269)
at AppView.detectChangesInternal (view.js:254)
at AppView.detectChanges (view.js:243)
at AppView.detectContentChildrenChanges (view.js:261)

and if i write ng-model error gone but i couldn’t fetch value.

could you post more code regarding your [(ngModel)]?

I’m interested by your html:

<ion-input type="text" [(ngModel)]="title"></ion-input> 

and ts

@Input() title:string = 'hello world';    


Below my code

<ion-content padding class="login">
    <ion-row class="login-logo">
        <ion-col><img src="img/icon.png" /></ion-col>
    <ion-row class="login-form">
            <ion-list inset>
                <ion-label><ion-icon name="person"></ion-icon></ion-label>
                <ion-input [(ngModel)]="userValue" placeholder="username" name="username" type="text"></ion-input>
                <ion-label><ion-icon name="lock"></ion-icon></ion-label>
                <ion-input [(ngModel)]="pwdValue" placeholder="password" type="password" name="password"></ion-input>
            <button (click)="onSubmit()" primary class="login-button">Login</button>
            <button (click)="forgotPwd()" class="create-account">Forgot Password</button>

ts file

this.userValue = ResponseString.getLoginId();
this.pwdValue = ResponseString.getLoginPassword();

this error start when i updated ionic framework from ionic 2 .beta 10 to ionic 2 beta 11

Thx. Could you also show me how do you define your variables userValue and pwdValue in your ts file?

I updated my previous code, did you define them as @Input()?

no ,i am not used @Input
please see below code

userValue : string;
pwdValue : string;

this.userValue = ResponseString.getLoginId();
this.pwdValue = ResponseString.getLoginPassword();

…and if you use @Input does that solve your problem?

and should you place your instantiation in the constructor or in onPageDidEnter() or something like that? but that’s probably not the error

i tried as u say…but it’s not solve the problem.

i added Alertcontroller in constructor .

umm well then can’t help more. maybe by having a look at your all ts file (at least declarations, constructor and import) otherwise I don’t know sorry

ohk…no problem…
thankx for quick reply. i think this problem generate because of update ionic beta 11

just for the record, I’ve got plenty of such bindings with Beta11 and it works fine, so I’m not sure that Beta11 itself is responsible for that. Maybe something you changed while you migrated? If that could help to lead you in the good way to find your problem…

Okay, just to double check, ResponseString.getLoginId() & ResponseString.getLoginPassword(), is not changing the models multiple times i.e. like called several times or something. Can you post the full code snippet?

If you have @angular/forms 0.3.0, downgrade to 0.2.0.

Problem was solved thank you

Good. For the record, how did you solved it?

i added below directive

1 Like

i have some other issue please help me.

think you should open a more detailed other ticket if you’ve got another problem so more people will notice it

i already open new topic please refer it