Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set default value in md-select

This is my angular code I want to set default value as 300mb

<label >RAM</label>
  <md-select ng-model="RAMVal">
    <md-option value="300mb" ng-selected="index == 1">300mb</md-option>
    <md-option value="400mb">400mb</md-option>
  </md-select>
like image 512
Lakmi Avatar asked Mar 03 '17 07:03

Lakmi


People also ask

How do you select a default value in mat select?

Just for information, you need to make sure the datatype of the default value matches with that of the options, for.eg, <mat-select [(value)]="heroes[0]. id"> <mat-option *ngFor="let hero of heroes" [value]="hero.id">{{ hero.name }}</mat-option> </mat-select> will work.

How do I disable MD Select?

mdSelect API Documentation This behavior can be disabled by using the md-no-asterisk attribute. By default, the select will display with an underline to match other form elements. This can be disabled by applying the md-no-underline CSS class.


1 Answers

Just add this

 ng-selected="true"

you can check in https://jsfiddle.net/rschmukler/0ju750xo/

like image 102
Levent Saatci Avatar answered Oct 05 '22 02:10

Levent Saatci