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

Commit b24b4ed

Browse files
author
Kent C. Dodds
committed
Merge pull request #430 from TheMcMurder/master
After running 6.23.4 code in my application I ran into a lot of perform…
2 parents cc8d851 + ab810f3 commit b24b4ed

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/directives/formly-field.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,14 +360,15 @@ function formlyField($http, $q, $compile, $templateCache, $interpolate, formlyCo
360360
function addFormatters() {
361361
setParsersOrFormatters('formatters');
362362
const ctrl = scope.fc;
363-
if (ctrl.$formatters) {
363+
if (scope.options.formatters) {
364364
let value = ctrl.$modelValue;
365365
ctrl.$formatters.forEach((formatter) => {
366366
value = formatter(value);
367367
});
368368

369369
ctrl.$setViewValue(value);
370370
ctrl.$render();
371+
ctrl.$setPristine();
371372
}
372373
}
373374

src/directives/formly-field.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1015,7 +1015,7 @@ describe('formly-field', function() {
10151015
expect(ctrl.$viewValue).to.equal('hello! boo!');
10161016
});
10171017

1018-
it(`should format a model value right from the start`, () => {
1018+
it(`should format a model value right from the start and the form should still be pristine`, () => {
10191019
scope.model = {myKey: 'hello'};
10201020
scope.fields = [getNewField({
10211021
key: 'myKey',
@@ -1026,6 +1026,8 @@ describe('formly-field', function() {
10261026
const ctrl = getNgModelCtrl();
10271027

10281028
expect(ctrl.$viewValue).to.equal('!hello!');
1029+
expect(ctrl.$dirty).to.equal(false);
1030+
expect(ctrl.$pristine).to.equal(true);
10291031
});
10301032

10311033
it.skip(`should handle multiple form controllers when formatting a model value right from the start`, () => {

0 commit comments

Comments
 (0)