angular-ui / ui-select2

AngularJS wrapper for select2 (deprecated, use angular-ui/ui-select)
https://github.com/angular-ui/ui-select
MIT License
595 stars 444 forks source link

Using directive within formatResult never compiles #278

Open zyadsherif opened 10 years ago

zyadsherif commented 10 years ago

I have a problem were am using the formatResult option returning a string that has html with gravatar-src directive, it's not working and I couldn't attach the ng-bind-html to the option element because I don't have access to the value yet before page load, code is below.

<!-- template -->
<select ui-select2="statusSelectOptions" name="" id="" ng-model="defaultStatus" ng-change="statusChange()">
    <option ng-repeat="statue in issue.status" value="{{statue.id}}">{{statue.name}}</option>
 </select>
//Controller
    $scope.statusSelectOptions = {
      formatResult: $rootScope.format_icons,
      formatSelection: $rootScope.format_icons,
      minimumResultsForSearch: -1,
      escapeMarkup: function(m) {
        return m;
      }
    };

//formatting method
    $rootScope.format_image = function(object) {
      var originalOption = object.element;
        return "<img class='user-thumb' gravatar-src='" +  originalOption.email + "'/>" + object.text;
      // else
      //   return "<img class='user-thumb' src='" +  "https://i0.wp.com/s3.amazonaws.com/instabug-pro/na_missing_avatar_new.png?ssl=1" + "'/>" + object.text;
    }