Skip to content

Commit fac071e

Browse files
eugefmgcrea
authored andcommitted
feat(dropdown): add active state to the dropdown items
1 parent 83e6f91 commit fac071e

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

src/dropdown/docs/dropdown.demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ angular.module('mgcrea.ngStrapDocs')
1111
.controller('DropdownDemoCtrl', function($scope, $alert) {
1212

1313
$scope.dropdown = [
14-
{text: '<i class="fa fa-download"></i>&nbsp;Another action', href: '#anotherAction'},
14+
{text: '<i class="fa fa-download"></i>&nbsp;Another action', href: '#anotherAction', active: true},
1515
{text: '<i class="fa fa-globe"></i>&nbsp;Display an alert', click: '$alert("Holy guacamole!")'},
1616
{text: '<i class="fa fa-external-link"></i>&nbsp;External link', href: '/auth/facebook', target: '_self'},
1717
{divider: true},

src/dropdown/dropdown.tpl.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<ul tabindex="-1" class="dropdown-menu" role="menu" ng-show="content && content.length">
2-
<li role="presentation" ng-class="{divider: item.divider}" ng-repeat="item in content">
2+
<li role="presentation" ng-class="{divider: item.divider, active: item.active}" ng-repeat="item in content">
33
<a role="menuitem" tabindex="-1" ng-href="{{item.href}}" ng-if="!item.divider && item.href" target="{{item.target || ''}}" ng-bind="item.text"></a>
44
<a role="menuitem" tabindex="-1" href="javascript:void(0)" ng-if="!item.divider && item.click" ng-click="$eval(item.click);$hide()" ng-bind="item.text"></a>
55
</li>

src/dropdown/test/dropdown.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ describe('dropdown', function () {
3333

3434
var templates = {
3535
'default': {
36-
scope: {dropdown: [{text: 'Another action', href: '#foo'}, {text: 'External link', href: '/auth/facebook', target: '_self'}, {text: 'Something else here', click: '$alert(\'working ngClick!\')'}, {divider: true}, {text: 'Separated link', href: '#separatedLink'}]},
36+
scope: {dropdown: [{text: 'Another action', href: '#foo'}, {text: 'External link', href: '/auth/facebook', target: '_self'}, {text: 'Something else here', click: '$alert(\'working ngClick!\')'}, {divider: true}, {text: 'Separated link', href: '#separatedLink', active: true}]},
3737
element: '<a bs-dropdown="dropdown">click me</a>'
3838
},
3939
'default-with-id': {
@@ -128,6 +128,7 @@ describe('dropdown', function () {
128128
expect(sandboxEl.find('.dropdown-menu a:eq(1)').attr('ng-click')).toBeUndefined();
129129
expect(sandboxEl.find('.dropdown-menu a:eq(2)').attr('href')).toBeDefined();
130130
expect(sandboxEl.find('.dropdown-menu a:eq(2)').attr('ng-click')).toBe('$eval(item.click);$hide()');
131+
expect(sandboxEl.find('.dropdown-menu li:eq(4)').attr('class')).toContain('active');
131132
});
132133

133134
it('should support ngRepeat markup', function() {

0 commit comments

Comments
 (0)