Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Add on-shown attribute #826

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/uiSelectController.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ uis.controller('uiSelectCtrl',

$scope.$broadcast('uis:activate');

$timeout(function(){
ctrl.onShowCallback($scope);
});

ctrl.open = true;

ctrl.activeIndex = ctrl.activeIndex >= ctrl.items.length ? 0 : ctrl.activeIndex;
Expand Down
3 changes: 2 additions & 1 deletion src/uiSelectDirective.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ uis.directive('uiSelect',

$select.onSelectCallback = $parse(attrs.onSelect);
$select.onRemoveCallback = $parse(attrs.onRemove);

$select.onShowCallback = $parse(attrs.onShow);

//Set reference to ngModel from uiSelectCtrl
$select.ngModel = ngModel;

Expand Down
23 changes: 22 additions & 1 deletion test/select.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -900,7 +900,7 @@ describe('ui-select tests', function() {

expect(scope.$item).toBeFalsy();
expect(scope.$model).toBeFalsy();

clickItem(el, 'Samantha');
$timeout.flush();

Expand All @@ -912,6 +912,27 @@ describe('ui-select tests', function() {

});

it('should invoke show callback on activate', function () {
scope.onShowFn = function (someArg) {
scope.someArg = someArg;
};
var el = compileTemplate(
'<ui-select on-show="onShowFn(\'shown\')" ng-model="selection.selected"> \
<ui-select-match placeholder="Pick one...">{{$select.selected.name}}</ui-select-match> \
<ui-select-choices repeat="person.name as person in people | filter: $select.search"> \
<div ng-bind-html="person.name | highlight: $select.search"></div> \
<div ng-bind-html="person.email | highlight: $select.search"></div> \
</ui-select-choices> \
</ui-select>'
);

expect(scope.someArg).toBeFalsy();
clickMatch(el);
$timeout.flush();

expect(scope.someArg).toEqual('shown');
});

it('should invoke hover callback', function(){

var highlighted;
Expand Down