isteven / angular-multi-select

A multi select dropdown directive for AngularJS. Allows you to use HTML tags and CSS in the data. Requires only AngularJS and nothing else.
isteven.github.io/angular-multi-select
MIT License
1.08k stars 518 forks source link

unable to access scope value #489

Closed ajayreddy56 closed 7 years ago

ajayreddy56 commented 7 years ago
<div ng-if="item.shareText">
 <textarea></textarea>
  <div>
    <select ng-model="shareOptions">
      <option value="PUBLIC" selected>public</option>
            <option value="FOLLOWERS">followers</option>
            <option value="INDIVIDUAL">individuals</option>
          </select>
          <div ng-if="shareOptions == 'INDIVIDUAL'">
          <div
          isteven-multi-select
          input-model="userFriends"
          output-model="outputUserFriends"
          button-label=" icon fullName"
          tick-property="ticked">
         </div>
     </div>
  </div>
</div>

in controller:

if($scope.shareOptions == 'INDIVIDUAL' && $scope.outputUserFriends.length == 0){
      $window.alert("Please select your INDIVIDUALS");
      return;
    }

Here outputUserFriends is showing the length as undefined.

isteven commented 7 years ago

@ajayreddy56 ,

Perhaps you can try to pre-define $scope.outputUserFriends as an empty array?

ajayreddy56 commented 7 years ago

done with that also. @isteven

isteven commented 7 years ago

@ajayreddy56 ,

If it doesn't work, then I guess I'll need you to replicate this in Plunker or JsFiddler so I can have a look.

ajayreddy56 commented 7 years ago

@isteven
i have a scenario like this,have drop down contains x,y and z. when click on z your selection will come and i selected one item there and come back to x ,and i navigated to z click on that same again showing here how to clear it.
used below code no use

 angular.forEach( $scope.userFriends, function( value, key ) {
    value['ticked'] = false;
  });
isteven commented 7 years ago

@ajayreddy56 ,

Please help to replicate your problem in Plunker or JsFiddler (or any other JS collaboration tools) so I can have a look.