Topic: Sidenav Dynamic mdb-item
itdev pro asked 6 years ago
Damian Gemza staff answered 6 years ago
optionsSelect: Array<any>; selectedValue:any= [ {value: '', label: ''} ]; ngOnInit() { this.selectedValue=this.optionsSelect; this.optionsSelect= [ { value: 'Link 1', label: 'Link 1' }, { value: 'Link 2', label: 'Link 2' }, { value: 'Link 3', label: 'Link 3' }, ]; }
<mdb-select [options]="optionsSelect" [(ngModel)]="selectedValue" placeholder="Choose your option"></mdb-select>
<mdb-item> <mdb-item-head mdbRippleRadius> <i class="fa fa-chevron-right"></i> Dynamic links</mdb-item-head> <mdb-item-body> <ul> <li> <a href="#" class="waves-effect" mdbRippleRadius>{{selectedValue}}</a> </li> </ul> </mdb-item-body> </mdb-item>
itdev pro commented 6 years ago
Are you able to default to Link 2 on load?Damian Gemza staff commented 6 years ago
For default select's value you have to follow instructions placed in our Material Select documentation: https://mdbootstrap.com/angular/advanced/material-select/#default-value And this value should be placed in ngAfterViewInit() to your nav link. Please try to experiment with my solution and these docs, and let me know. if something won't work for you. Best Regards, DamianFREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Resolved
- ForumUser: Pro
- Premium support: No
- Technology: MDB Angular
- MDB Version: -
- Device: -
- Browser: -
- OS: -
- Provided sample code: No
- Provided link: No