0

I have a problem with an old AngularJS APP where I have to manage selection.

basically I am trying to modify the array of selectedItems with ng-click

but it does not react to changes to the array, it firs with logs but not when I want to splice or push.

Any idea why this might happen?

` Categories/Subcategories {{ category.category.name }}

 <div ng-repeat="subcategory in category.sub_categories"> <md-option ng-value="subcategory.id" class="subcategory-name" ng-click="productCtrl.toggleSelection(category.category.id, subcategory.id)" > {{subcategory.name}} </md-option> </div> </div> </md-optgroup> </md-select> </md-input-container>` 

I really would like to keep this as ng-click because of simplicity.

Behind the hood I have a toggle function where I manage the selection.

Thanks in advance

2
  • Can you share also some javascript code?CommentedFeb 26, 2024 at 14:57
  • Hey! The task itself was a bit complex - I had a large array returned from the backend and the point was to manage parent-child relationship within cat-sub_cat. I changed my approach - I used the array just the display the selected items, but the state itself - I did it with object to avoid repeated loops.It's a really disorganised angular code with 3000 lines on code in one file. It worked well and instead of using ng-click - I used ng-change. which also had some downside - because it detect the change too early on a first load in my web page and I had to manage the fetch just to load once.
    – Izabela O
    CommentedMar 1, 2024 at 9:21

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.