md-chips-select icon indicating copy to clipboard operation
md-chips-select copied to clipboard

Doesn't update list on change to select-items

Open tellingson opened this issue 9 years ago • 6 comments

This only works with a static list because you do the select-items parsing on load. The parse needs to happen any time the select-items list changes. For example, pulling the list of items in an http request. I solved it setting up a watch on selectItems and parsing it any time that it changes.

scope.$watch('selectItems', function (newValue, oldValue) {
      if (newValue === oldValue) {
          return;
      }
      scope.mdSelectItems = newValue;
      parseSelectedItems();
 })

  function parseSelectedItems() {
      angular.forEach(scope.mdSelectItems, function (obj, key) {
          obj.mainTitle = '';
          angular.forEach(subString, function (field, fkey) {
              if (obj[field] != null) {
                  obj.mainTitle += obj[field].toString();
                  obj.mainTitle += ' ';
              }
          });
      });
  }

tellingson avatar Jan 16 '16 15:01 tellingson

Actually, I ended up having to make quite a few more changes to get this to work properly. If you would like me to post my code/submit a pull request let me know. Otherwise, I will leave it in your capable hands to fix as you see fit.

tellingson avatar Jan 16 '16 16:01 tellingson

It's great yo use your code!

On Sat, Jan 16, 2016 at 8:54 AM, tellingson [email protected] wrote:

Actually, I ended up having to make quite a few more changes to get this to work properly. If you would like me to post my code/submit a pull request let me know. Otherwise, I will leave it in you capable hands to fix as you see fit.

— Reply to this email directly or view it on GitHub https://github.com/qqnc/md-chips-select/issues/2#issuecomment-172226726.

nch3ng avatar Jan 20 '16 18:01 nch3ng

@tellingson would be nice to see how you resolved this issue, can you submit a PR?

designnotdrum avatar Feb 22 '16 19:02 designnotdrum

Hello, It will be super cool to have the list dynamic. In my case I load the list from an api http request.

tidjean avatar Jan 16 '17 07:01 tidjean

Hello, is there anyway to retrieve chipInput keyword used for search. would really appreciate your help. Regards

mbelghazi avatar Mar 03 '17 16:03 mbelghazi

@qqnc @tellingson Still stuck with this, doesn't update when you need to use a dynamic list from http through a service like so

$scope.sItems = [];
obtainSamthingFromServer.getThenceFromServer(false)
            .then(function (response) {
                $scope.sItems = response;
                console.log($scope.sItems); //Shows my dynamic object but does not update the dropdown in ui
            });

ratatatKE avatar Jul 17 '17 16:07 ratatatKE