ui-select2 and directives
Is there anything I need to consider while wrapping ui-select2 inside a custom directive? I am trying to set the select2Options in the link function but those settings never get picked up. Is there anything i am missing?
link: function(scope, elem, attrs) {
scope.select2Options = {
'placeholder': 'myplaceholder'
};
}
and my html looks like this:
<select style="width:100%;" ui-select2="select2Options" multiple ng-model="select2">
Because when uiselect2 is being linked there is no select2Options in the scope. Check this http://stackoverflow.com/questions/17353189/how-can-i-pass-option-changes-to-angular-ui-ui-select2
Also here http://stackoverflow.com/questions/17353189/how-can-i-pass-option-changes-to-angular-ui-ui-select2
If you associate the options with the scope in a directive controller instead of link it picks up the settings (at least that worked for me):
controller: function($scope, $element, $attrs) {
$scope.select2Options = {
'placeholder': 'myplaceholder'
};
}
That way, if the options don't change later on, there is no need to watch them.
Wrap ui-select2 inside a custom directive is not work.
It can be work like this:
app.controller('CountryController', ['$scope',
function ($scope) {
$scope.getCountry = {
...
};
}
]);