Izabela O
Izabela O

Reputation: 1

ng-click does not modify array

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

Upvotes: 0

Views: 22

Answers (0)

Related Questions