Skip to content
This repository has been archived by the owner on May 21, 2021. It is now read-only.

Commit

Permalink
feat(api): expose controller with open, close and toggle function via…
Browse files Browse the repository at this point in the history
… w11k-select attribute value to parent scope
  • Loading branch information
Philipp Burgmer authored and Can Kattw committed May 18, 2017
1 parent 802047e commit 2b71876
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/w11k-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,27 @@ angular.module('w11k.select').directive('w11kSelect', [
templateUrl: w11kSelectConfig.common.templateUrl,
scope: {},
require: 'ngModel',
controller: function ($scope, $attrs, $parse) {
if ($attrs.w11kSelect && $attrs.w11kSelect.length > 0) {
var exposeExpression = $parse($attrs.w11kSelect);

if (exposeExpression.assign) {
exposeExpression.assign($scope.$parent, this);
}
}

this.open = function () {
$scope.dropdown.open();
};

this.close = function () {
$scope.dropdown.close();
};

this.toggle = function () {
$scope.dropdown.toggle();
};
},
compile: function (tElement, tAttrs) {
var configExpParsed = $parse(tAttrs.w11kSelectConfig);
var optionsExpParsed = w11kSelectHelper.parseOptions(tAttrs.w11kSelectOptions);
Expand Down

0 comments on commit 2b71876

Please sign in to comment.