Topic: Dropdown load selected item
                  
                  kjimenezdev
                  pro
                  asked 8 years ago
                
                Hi, is there a way to load items on mdb dropdown component using angular 4 and set one item as the currently selected one?
                
                  
                
                
                
                  
                  
                  
                    
                    
                
              
              
              
            
                      
                        Add comment
                      
                    
                  
                
                      
                      Dawid Adach
                      pro
                        answered 8 years ago
                    
Dear kijmenezdev,
Sure, you can easily do that:
component.html:
<div class="btn-group" dropdown>
<buttondropdownToggletype="button"class="btn btn-primary dropdown-toggle waves-light"mdbRippleRadius>
Basic dropdown
</button>
<divclass="dropdown-menu dropdown-primary">
<li role="menuitem" *ngFor="let link of links"><a class="dropdown-item" [class.active]="link.isActive"href="{{link.url}}">{{link.name}}</a></li>
</div>
</div>
Component.ts:
links= [
{id: 1, name: 'Google', url: 'http://google.com', isActive: false},
{id: 2, name: 'Microsfot', url: 'http://microsoft.com', isActive: false},
{id: 3, name: 'Facebook', url: 'http://facebook.com', isActive: true},
{id: 4, name: 'Yahoo', url: 'http://yahoo.com', isActive: false},
];
                    
                      FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Status
              Answered
Specification of the issue
              - ForumUser: Pro
 - Premium support: No
 - Technology: MDB Angular
 - MDB Version: -
 - Device: -
 - Browser: -
 - OS: -
 - Provided sample code: No
 - Provided link: No
 
Tags