Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aredev's avatar

Dusk and selecting dropdown value created by ng-options

Hello all,

I have a Laravel application which uses some Angular JS for some pages. I have used the ng-options directive to create a dropdown menu. As values I am using the javascript objects, since this some other logic on that page relies on it. However, it is hard to test that page using Dusk since the value of those select boxes are all in the form 'Object:xx' where xx is a number.

Is there a way to deal with this or should I use the id's of the objects instead of the objects themselve?

I hope someone knows a solution, it would be nice to just keep using the objects.

Kind regards,

Ap

0 likes
1 reply
aredev's avatar
aredev
OP
Best Answer
Level 1

I found the solution.

So if you want to have the value in your controller as an object, but want the html value to be the id (for example) then you need to add to your ngOptions/ngRepeat directive:


track by <your_unique_value>

Angular will use <your_unique_value> as the value for the html, you can use that in the Dusk tests but remain the logic with the objects.

1 like

Please or to participate in this conversation.