Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/input/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,12 @@ function inputTextareaDirective($mdUtil, $window, $mdAria, $timeout, $mdGesture)

scope.$watch(isErrorGetter, containerCtrl.setInvalid);

// When the developer uses the ngValue directive for the input, we have to observe the attribute, because
// Angular's ngValue directive is just setting the `value` attribute.
if (attr.ngValue) {
attr.$observe('value', inputCheckValue);
}

ngModelCtrl.$parsers.push(ngModelPipelineCheckValue);
ngModelCtrl.$formatters.push(ngModelPipelineCheckValue);

Expand Down
12 changes: 12 additions & 0 deletions src/components/input/input.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,18 @@ describe('md-input-container directive', function() {
expect(el).not.toHaveClass('md-input-has-value');
});

it('should set has-value class on container with ng-value', function() {
var el = setup('ng-value="value"');

pageScope.$apply('value = "My Value"');

expect(el).toHaveClass('md-input-has-value');

pageScope.$apply('value = ""');

expect(el).not.toHaveClass('md-input-has-value');
});

it('should set has-value class on container for ng-model input', function() {
pageScope.value = 'test';
var el = setup('ng-model="value"');
Expand Down