0

I have make a demo of angularj dropdown menu,and its working fine,But now i want to make selected item as active,I dont have any idea how to do this,can anybuddy please help me ,I have used Angular-Dropdown.js

Mycode is as below:

html

<span class="toolbar-button--quiet navigation-bar__line-height" style="border: none; padding: 0">
                <i  class="ion-android-more-vertical" dropdown-disabled="isDropdownDisabled" style="font-size: 26px; margin: 0; padding: 0 17px 0 12px;" dropdown-menu="ddMenuOptions" dropdown-model="ddMenuSelected" dropdown-disabled="dropdownsDisabled"></i>  
            </span>

js

  $scope.ddMenuOptions = [
        {
            text: 'Featured',
            code: 'F'
        }, {
            text: 'Name (A-Z)',
            code: 'A'
        }, {
            text: 'Rating',
            code: 'M'
        }, {
            text: ' Most Popular',
            code: 'MP'
        }
    ];

    $scope.ddMenuSelected = {
    };



    $scope.$watch("ddMenuSelected", function(newValue, oldValue) {

        $scope.selectedItem = newValue;
        var result = document.getElementsByClassName("dropdown");
        var wrappedResult = angular.element(result);
        wrappedResult.removeClass('active');
        wrappedResult.addClass('activated');
        if (newValue !== oldValue) {

            console.log("=========" + $scope.ddMenuSelected.code);
            $rootScope.ddMenuOptions = false;

1 Answer 1

1

set divider to true/false

example:

$scope.ddSelectOptions[0].divider = false;

or

$scope.ddSelectOptions[1].divider = true;

https://jsfiddle.net/66mrssb7/7/

Sign up to request clarification or add additional context in comments.

9 Comments

tried your code inside $watch but nothing is happening.
I made a simple example. It can exactly choice the specified option. jsfiddle.net/66mrssb7
Oh,Thanks frend,but its not what i need,I want to make option as active when i again open dropdown,just same as you have made *label as active in your example,(active seems it should display different than other items).you get my question dear?please help me.
You can set "divider" to true/false. $scope.ddSelectOptions[1].divider = true; $scope.ddSelectOptions[0].divider = false; is that what you want? jsfiddle.net/66mrssb7/5
Exaclty great,but how to do this on dropdown selection,i mean where to write down this code is the problem..:(
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.