1

md-select not working in my code. I imported every css and js files needed for angular so dont say to import files properly. I'm building a web application. I'm almost done with that but on client side validation <md-select> not working.

<md-input-container class="md-block" style="margin-bottom: 0px;padding:2px;">
    <md-select name="gender" ng-model="gender" ng-required="true" >
    <label value="gender" style="padding-left: 13px">Gender</label>
        <md-option value="male">Male</md-option>
        <md-option value="female">Female</md-option>
        <md-option value="others">Others</md-option>
    </select>
    <div class="errors" ng-messages="form.gender.$error">
         <div ng-message="required">Please Select Your Gender</div>
     </div>
 </md-input-container>

It should work fine but for me it's not working it shows error but redirects to next page. So please someone solve my issue.

6
  • any error in console ? Commented Dec 1, 2016 at 4:58
  • no error has been displayed Commented Dec 1, 2016 at 5:00
  • <md-select name="gender" ng-model="gender" ng-required="true" > <label value="gender" style="padding-left: 13px">Gender</label> <md-option value="male">Male</md-option> <md-option value="female">Female</md-option> <md-option value="others">Others</md-option> </md-select> <div class="errors" ng-messages="form.gender.$error"> <div ng-message="required">Please Select Your Gender</div> </div> Commented Dec 1, 2016 at 5:04
  • this is my final code Commented Dec 1, 2016 at 5:04
  • Is this Angular 2.x or AngularJS 1.x question? Why tag both? Commented Dec 1, 2016 at 8:41

2 Answers 2

1
<body ng-controller="myCtrl">
  <md-select name="gender" ng-model="gender" ng-required="true">
    <label value="gender" style="padding-left: 13px">Gender</label>
    <md-option value="male">Male</md-option>
    <md-option value="female">Female</md-option>
    <md-option value="others">Others</md-option>
  </md-select>
  <div class="errors" ng-messages="form.gender.$error">
    <div ng-message="required">Please Select Your Gender</div>
  </div>
</body>

DEMO

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

4 Comments

you are mixing both angular and bootstrap , go through the documentation material.angularjs.org/latest/layout/introduction
my problem is not with bootstrap and angular my problem is md-select is not working on my code . you got it man?
@dharmanraj that is the issue! your app is not at all angular material
check this demo and apply the same codepen.io/sajeetharan/pen/KNyObN
0

md-select not validating anymore so use select in the md-input-container. i solved this issue by following the github angular issue page.

Comments

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.