Primeng: AutoComplete Doesn't Refresh OnInit

Created on 24 Jul 2017  路  4Comments  路  Source: primefaces/primeng

There is no guarantee in receiving a response in GitHub Issue Tracker, If you'd like to secure our response, you may consider PrimeNG PRO Support where support is provided within 4 business hours

I'm submitting a ... (check one with "x")

[ X ] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case (Bug Reports)
http://plnkr.co/edit/UaSrrAMsSv4zWoNpP6Wz?p=preview

Current behavior

Trying to load options into the model OnInit doesn't properly load the options

Expected behavior

Objects should be loaded into the component

Minimal reproduction of the problem with instructions

We are using this component in a form that is editable. When we try to load stored data from our API into the application, the component doesn't show the existing selected options initially.

What is the motivation / use case for changing the behavior?

See above

Please tell us about your environment:

macOS 10.11

  • Angular version: 4.1.3

  • PrimeNG version: 4.1.0-rc.3

  • Browser: [ Chrome XX | Firefox XX | Safari XX ]

  • Language: [all]

  • Node (for AoT issues): node --version =

All 4 comments

I played with your plunkr, and changed ngOnit() to ngOnInit() and it worked fine. Hopefully that works for you as well.

Thanks, @BearInHat. That was my bad.

We still had the issue in our application, but I think it has to do with how the model and field are rendered. (They're being dynamically generated.)

I actually just figured out a solution for us, and posted it on my forum thread as well: https://forum.primefaces.org/viewtopic.php?f=35&t=51823&p=158674#p158674

@ericrovtar that's a good one to have in the quiver, thanks.
ngAfterViewInit has saved me with dynamic content a couple times, recently with tabViews. Since we're sharing, here's a very simplified version of that.

Ya. We just had a similar issue with the DataTable and sortOrder. We wanted to manually update it during the API call, but that make the table out of sync. As long as you remember the setTimeout, ngAfterViewInitis a good friend.

Was this page helpful?
0 / 5 - 0 ratings