2

Good day! I need to create directive with ui-select inside.
Here is directive's controller and template:

app.controller("servicesCtrl", ["$resource", '$scope', function($resource, $scope){
    $scope.clinicServices = [];
    console.log($scope.data);
    var Services = $resource(window.baseurl + "services/getAllbyClinic", null, {
        get:{responceType: "JSON", isArray: false, method: 'POST'}
    });
    $scope.refresh = function(service){
        if(service.length < 1) return false;
        Services.get({service: service},function(data){
            $scope.clinicServices = data.services;
        });
    };
}]);
<ui-select 
     multiple 
     tagging 
     tagging-label="false" 
     ng-model="$parent.data" 
     theme="bootstrap" 
     title="Выберите услугу" 
     search-enabled="true"
>
    <ui-select-match placeholder="Введите услугу">{{$item.name}}</ui-select-match>
    <ui-select-choices repeat="clinicService in clinicServices" refresh="refresh($select.search)">
        <div ng-bind-html="(clinicService.name | highlight: $select.search)"></div>
    </ui-select-choices>
</ui-select>
{{data}}

And here is directive initialization.

app.directive('services', function() {
    return {
        restrict: 'E',
        templateUrl: window.baseurl + 'views/services',
        scope: {
            data: "=ngModel"
        },
        controller: "servicesCtrl",
        controllerAs: "services"
    }
});
<services ng-model="meEvent.services"></services>

Can't render $scope.data into view from servicesCtrl to edit previously selected data.
There are an object inside $scope.data, but empty view's field. I tried ng-model="$parent.data" and ng-model="data", but have no effect.

Nicollo
  • 21
  • 4
  • Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackoverflow.com/rooms/77809/discussion-on-question-by-nicollo-angularjs-ui-select-trouble-with-creating-cust). – Taryn May 14 '15 at 13:51

1 Answers1

0

There where errors in my version of ui-select library

Nicollo
  • 21
  • 4