3

How can we access to angular ui-select's $select from angular component?

The sample given on the documentation deals with directive, but I am not using directives I am using components.

I have tried to require uiSelect in the component with this command require: { uiSelectController: '^uiSelect'} but I got an error Error: [$compile:ctreq] Controller 'uiSelect', required by directive 'myUiSelect', can't be found!

Here is a sample of code of my component (I insist, I am not using directive but component) :

    (function () {
    'use strict';

    var myUiSelect = {
        bindings: {
            label: '<'
        },
        controller: MyUiSelectController,
        require: { uiSelectController: '^uiSelect'},
        templateUrl: '/components/ui-select/my-ui-select.tpl.html'
    };

    MyUiSelectController.$inject = [];

    function MyUiSelectController() {

        var ctrl = this;
        ctrl.init = init;

        function init() {
            console.log('ctrl.uiSelectController.$select' + ctrl.uiSelectController.$select);
        }

        ctrl.$onInit = ctrl.init;

    }

    angular
        .module('core.components')
        .component('myUiSelect', myUiSelect);
})();
Moussa
  • 4,066
  • 7
  • 32
  • 49

0 Answers0