alexandernst / angular-multi-select

A multi select dropdown directive for AngularJS.
http://alexandernst.github.io/angular-multi-select
MIT License
59 stars 26 forks source link

multiple angular-multi-select controls using dynamic scope variables #91

Closed hectorcaban closed 8 years ago

hectorcaban commented 8 years ago

I am creating multiple drop downs dynamically using a json file as a configuration for my application. Everything seems to work fine but I cant observe the output-model of each control using the $watchCollection funciton. Here is my code

... ``` $scope.getoutput_data = function (filter) { $scope[filter.id + '_menu_output_data'] = []; $scope.$watchCollection( function getValue() { return $scope[filter.id + '_menu_output_data']; }, function (newValue, oldValue) { console.log( "New value: %s , Was value: %s.", JSON.stringify(newValue), JSON.stringify(oldValue) ); } ); return $scope[filter.id + '_menu_output_data']; } ```
alexandernst commented 8 years ago

Very interesting. Let me build a demo and try it

alexandernst commented 8 years ago

I had time to test your code and it's working fine here. https://plnkr.co/edit/5vrRIWqT66PrJRZCPKwQ?p=preview

Are you sure filter.id contains a valid value? Also, what version of Angular are you using?

hectorcaban commented 8 years ago

It was my mistake. I am still new to angular. I noticed a new scope was created during ng-repeat.

alexandernst commented 8 years ago

Ok, I'll close the issue then.