Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 9d6087d

Browse files
feat(ngModel): provide ng-empty and ng-not-empty CSS classes
If the `$viewValue` is empty then the `ng-empty` CSS class is applied to the input. Conversely, if it is not empty the `ng-not-empty` CSS class is applied. Emptiness is ascertained by calling `NgModelController.$isEmpty()` Closes #10050
1 parent 2b046f9 commit 9d6087d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/ng/directive/ngModel.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
319319
};
320320

321321
this.$$updateEmptyClasses = function(value) {
322-
if (this.$isEmpty(value)) {
322+
if (ctrl.$isEmpty(value)) {
323323
$animate.removeClass($element, NOT_EMPTY_CLASS);
324324
$animate.addClass($element, EMPTY_CLASS);
325325
} else {

test/ng/directive/ngModelSpec.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,9 @@ describe('ngModel', function() {
13281328
describe('CSS classes', function() {
13291329
var EMAIL_REGEXP = /^[a-z0-9!#$%&'*+\/=?^_`{|}~.-]+@[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/i;
13301330

1331-
it('should set ng-empty or ng-not-empty the view value changes', inject(function($compile, $rootScope, $sniffer) {
1331+
it('should set ng-empty or ng-not-empty when the view value changes',
1332+
inject(function($compile, $rootScope, $sniffer) {
1333+
13321334
var element = $compile('<input ng-model="value" />')($rootScope);
13331335

13341336
$rootScope.$digest();

0 commit comments

Comments
 (0)