This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(select): add styles for invalid
- Loading branch information
1 parent
e0f9fe9
commit ddf1198
Showing
7 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div ng-app="selectDemoBasic" ng-controller="AppCtrl" layout="column" layout-align="center center" style="min-height: 300px;"> | ||
<form name="myForm"> | ||
<p>Note that invalid styling only applies if invalid and dirty</p> | ||
<md-input-container> | ||
<md-select name="myModel" placeholder="Pick" ng-model="myModel" required> | ||
<md-option value="1">One</md-option> | ||
<md-option value="2">Two</md-option> | ||
</md-select> | ||
<div class="errors" ng-messages="myForm.myModel.$error" ng-if="myForm.$dirty"> | ||
<div ng-message="required">Required</div> | ||
</div> | ||
</md-input-container> | ||
<div layout="row"> | ||
<md-button ng-click="clearValue()" ng-disabled="!myModel" style="margin-right: 20px;">Clear</md-button> | ||
<md-button ng-click="save()" ng-disabled="myForm.$invalid" class="md-primary" layout layout-align="center end">Save</md-button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
angular.module('selectDemoBasic', ['ngMaterial', 'ngMessages']) | ||
.controller('AppCtrl', function($scope) { | ||
$scope.clearValue = function() { | ||
$scope.myModel = undefined; | ||
}; | ||
$scope.save = function() { | ||
alert('Form was valid!'); | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
p { | ||
padding: 0 20px; | ||
text-align: center; | ||
} | ||
|
||
p.result { | ||
font-size: 0.8em; | ||
color: #777; | ||
} | ||
|
||
|
||
.demo-content { | ||
min-height: 348px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ddf1198
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rschmukler I think style for ng-messages should support also ng-messages element and not just attribute.
see https://docs.angularjs.org/api/ngMessages/directive/ngMessages
ddf1198
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kugler - please submit a new issue for your request.
ddf1198
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rschmukler --
There should be some padding added so both label and error message can be displayed
Error Message active:
Error Message inactive:
Also, the provided demo only shows the error message if something is selected then cleared. But clicking on it, and not selecting anything doesnt change anything. Removing the ng-if $dirty clears this up.
ddf1198
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another note, Input doesnt color the placeholder text red: