angular-ui / ui-select2

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

$compile doesn't work with options #35

Open BirdInTheCity opened 11 years ago

BirdInTheCity commented 11 years ago

I'm trying to $compile some HTML that I'm passing to my Select2 instance for the option formatNoMatches. Unfortunately, it doesn't seem to be rendering correctly. I'm not sure if this is a bug, or simply another Angular concept that I don't yet understand.

$scope.myResponse = $compile('<div style="text-align: center"><h6 class="text-    warning bigger" >No vendors found.</h6><button class="btn btn-primary btn-app btn-small" ng-click="noReturns()"><i class="icon-edit"></i>Add New</button></div>')($scope);
$scope.vendorOptions = {
     formatNoMatches:function(){
         return $scope.myResponse;
     }
};
joshkurz commented 11 years ago

couldn't you just use ngshow or ngIf on the html you want to show on return and in the anonymous function just set your conditional variable to true or false depending on the params?

Thanks Josh Kurz (mobile)

----- Reply message ----- From: "Brian Bird" notifications@github.com To: "angular-ui/ui-select2" ui-select2@noreply.github.com Subject: [ui-select2] $compile doesn't work with options (#35) Date: Mon, Jun 24, 2013 10:54 PM I'm trying to $compile some HTML that I'm passing to my Select2 instance for the option formatNoMatches. Unfortunately, it doesn't seem to be rendering correctly. I'm not sure if this is a bug, or simply another Angular concept that I don't yet understand.

$scope.myResponse = $compile('

No vendors found.
')($scope); $scope.vendorOptions = { formatNoMatches:function(){ return $scope.myResponse; } };

— Reply to this email directly or view it on GitHub.

BirdInTheCity commented 11 years ago

But I want the button to be included in the select2 box, not outside of it.