Skip to content
This repository has been archived by the owner on Sep 8, 2020. It is now read-only.

Enable watching on nested ng-repeats. #177

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Enable watching on nested ng-repeats. #177

wants to merge 1 commit into from

Conversation

stereosteve
Copy link

For the case when you have two nested ng-repeats: an outer one for optgroup and an inner repeat for the options.

For example:

// using underscore's groupBy function
$scope.groupedCities = _.groupBy(cities, 'state')
<select ui-select2 multiple>

  <optgroup
    ng-repeat="(state, cities) in groupedCities"
    label="{{ state }}">

    <option
      ng-repeat="city in cities"
      ng-value="city.name">
      {{ city.name }}
    </option>

  </optgroup>

</select>

The current implementation only looks for ng-repeat on an option element - in this case it causes a scoping issue, because cities is only defined inside of the parent ng-repeat. As a result the initial value would not be set correctly.

This change caused an error to sometimes be thrown on this line:

// Set initial value - I'm not sure about this but it seems to need to be there
elm.select2('data', controller.$modelValue);

Removing it fixed the problem - all the tests pass and everything worked correctly, but I didn't figure out why.

I can add a test for nested ng-repeat just wanted to get some feedback first...

@just-boris
Copy link

It seems to build failed with not related to the pull request error. Someone from @angular-ui can restart the build again.
@stereosteve you also can do it, by pushing this changes again using:

git commit --amend
git push -f origin nested_items

I'd like this pull request, so I want to see this changes are merged sooner
It seems to build failed with not related to the pull request error. Someone from @angular-ui can restart the build again.
@stereosteve you also can do it, by pushing this changes again using:

git commit --amend
git push -f origin nested_items

I'd like this pull request, so I want to see it merged

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants