andrucz / ionic2-rating

:star: Angular star rating bar. Built for Ionic 2+.
MIT License
178 stars 62 forks source link

Isn't updating the rate value #29

Closed felipelopes6 closed 6 years ago

felipelopes6 commented 6 years ago

When I set the rootPage the EvaluateComponent (Component that have the rating module) in my app.component that works fine.

But when I set my rootPage an other component, like the login component, and go to the rating page, doesn't update the rate values.

when The rootPage is other Page: doesnt-working

when the rootPage is the rating page: working

ps: the NgModel is updating in the console!

andrucz commented 6 years ago

Hello Felipe. Could you please check if there is any error in the console when the problem happens?

felipelopes6 commented 6 years ago

@andrucz nop, thats works fine, hasn't any error, until the rate is updating in the console. the problem is the view that dont update

felipelopes6 commented 6 years ago

screen shot 2017-12-05 at 08 51 35

@andrucz

andrucz commented 6 years ago

I remember doing something like that and it worked. Could you isolate this problem and share the code with me?

felipelopes6 commented 6 years ago

Can I put some parts of code here? @andrucz

andrucz commented 6 years ago

Sure. Let me know how the variables are created, how you make the transitions between pages, etc

felipelopes6 commented 6 years ago

evaluate.html

<form (ngSubmit)="rateService()" #loginForm="ngForm">

    <div class="evaluate-item">
      <h4>Atendimento</h4>
      <rating [(ngModel)]="rateDate.attendance"
        readOnly="false"
        max="5"
        emptyStarIconName="checkmark-circle-outline"    
        starIconName="checkmark-circle"
        nullable="false"
        name="attendance">
      </rating>
    </div>

    <div class="evaluate-item">
      <h4>Preço</h4>
      <rating [(ngModel)]="rateDate.price"
        readOnly="false"
        max="5"
        emptyStarIconName="checkmark-circle-outline"    
        starIconName="checkmark-circle"
        nullable="false"
        name="price">
      </rating>
    </div>

    <div class="evaluate-item">
      <h4>Qualidade do Serviço</h4>
      <rating [(ngModel)]="rateDate.quality"
        readOnly="false"
        max="5"
        emptyStarIconName="checkmark-circle-outline"    
        starIconName="checkmark-circle"
        nullable="false"
        name="quality">
      </rating>
    </div>

    [.....]

    <div class="evaluate-button">
      <button class="pa-button button-blue-dark" type="submit">
        Avaliar
      </button>
    </div>

  </form>

evaluate component

export class ServiceEvaluateNowComponent { 
  rateDate:any = {};

  constructor(private nav: NavController) { }

  public rateService() {
    console.log('rateDate', this.rateDate);
  }

}

evaluate module

import { NgModule } from '@angular/core';
import { SharedModule } from './../../../app/shared/shared.module';
import { ServiceEvaluateNowComponent } from './service-evaluate-now.component';
import { Ionic2RatingModule } from 'ionic2-rating';

@NgModule({
  imports: [
    SharedModule,
    Ionic2RatingModule
  ],
  declarations: [
    ServiceEvaluateNowComponent    
  ],
  entryComponents: [
    ServiceEvaluateNowComponent
  ],
  exports: [
    ServiceEvaluateNowComponent
  ]
})

export class ServiceEvaluateNowModule { }

app component

@Component({
  templateUrl: 'app.html'
})
export class MyApp {

  rootPage:any = LoginComponent;
  @ViewChild(Nav) nav: Nav;
}
......
felipelopes6 commented 6 years ago

in the preview page I only do a nav.push to the evaluate page

felipelopes6 commented 6 years ago

I declare the rating component in the evaluate module ServiceEvaluateNowModule and declare in the app.module

andrucz commented 6 years ago

Ok. I will take a look as soon as possible. I am at office right now.

felipelopes6 commented 6 years ago

ok, thanks very much @andrucz

andrucz commented 6 years ago

@felipel90 I've just created an application following the problem description: https://github.com/andrucz/ionic2-rating-issue29

It seems like it's working, no matter what I set as the root page.

Could you please clone that repo, test and see if I am missing some detail?

felipelopes6 commented 6 years ago

yep, I'll test, and return you, tks

felipelopes6 commented 6 years ago

this is the same way that I done. But doesn't work again! :(

Can you pass your email? I can share my code with you there.

andrucz commented 6 years ago

Do you mean that the example worked or not? Sorry, I didn't get It. Sure. andrucz@gmail.com

felipelopes6 commented 6 years ago

@andrucz the example Works fine. I'll contact you.

felipelopes6 commented 6 years ago

I fixed it, the problem was the map in the previous view.