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

Commit 602cf76

Browse files
committed
v8.0.4
2 parents 3b25b1e + e5ff572 commit 602cf76

File tree

6 files changed

+35
-19
lines changed

6 files changed

+35
-19
lines changed

dist/formly.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* angular-formly JavaScript Library v8.0.3
2+
* angular-formly JavaScript Library v8.0.4
33
*
44
* @license MIT (http://license.angular-formly.com)
55
*
@@ -153,7 +153,7 @@ return /******/ (function(modules) { // webpackBootstrap
153153

154154
ngModule.constant('formlyApiCheck', _providersFormlyApiCheck2['default']);
155155
ngModule.constant('formlyErrorAndWarningsUrlPrefix', _otherDocsBaseUrl2['default']);
156-
ngModule.constant('formlyVersion', ("8.0.3")); // <-- webpack variable
156+
ngModule.constant('formlyVersion', ("8.0.4")); // <-- webpack variable
157157

158158
ngModule.provider('formlyUsability', _providersFormlyUsability2['default']);
159159
ngModule.provider('formlyConfig', _providersFormlyConfig2['default']);
@@ -430,7 +430,7 @@ return /******/ (function(modules) { // webpackBootstrap
430430
Object.defineProperty(exports, "__esModule", {
431431
value: true
432432
});
433-
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("8.0.3") + "/other/ERRORS_AND_WARNINGS.md#";
433+
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("8.0.4") + "/other/ERRORS_AND_WARNINGS.md#";
434434
module.exports = exports["default"];
435435

436436
/***/ },
@@ -2054,7 +2054,7 @@ return /******/ (function(modules) { // webpackBootstrap
20542054
if (attrs.hasOwnProperty('isFieldGroup') && el.parent().parent().hasClass('formly')) {
20552055
parentFormAttributes = copyAttributes(el.parent().parent()[0].attributes);
20562056
}
2057-
return '\n <' + rootEl + ' class="formly"\n name="' + getFormName() + '"\n role="form" ' + parentFormAttributes + '>\n <' + fieldRootEl + ' formly-field\n ng-repeat="field in fields ' + getTrackBy() + '"\n ' + getHideDirective() + '="!field.hide"\n class="formly-field"\n options="field"\n model="field.model"\n original-model="model"\n fields="fields"\n form="theFormlyForm"\n form-id="' + getFormName() + '"\n form-state="options.formState"\n form-options="options"\n index="$index">\n </' + fieldRootEl + '>\n <div ng-transclude class="' + getTranscludeClass() + '"></div>\n </' + rootEl + '>\n ';
2057+
return '\n <' + rootEl + ' class="formly"\n name="' + getFormName() + '"\n role="form" ' + parentFormAttributes + '>\n <' + fieldRootEl + ' formly-field\n ng-repeat="field in fields ' + getTrackBy() + '"\n ' + getHideDirective() + '="!field.hide"\n class="formly-field"\n options="field"\n model="field.model || model"\n original-model="model"\n fields="fields"\n form="theFormlyForm"\n form-id="' + getFormName() + '"\n form-state="options.formState"\n form-options="options"\n index="$index">\n </' + fieldRootEl + '>\n <div ng-transclude class="' + getTranscludeClass() + '"></div>\n </' + rootEl + '>\n ';
20582058

20592059
function getRootEl() {
20602060
return attrs.rootEl || 'ng-form';
@@ -2144,7 +2144,7 @@ return /******/ (function(modules) { // webpackBootstrap
21442144
if (field.hideExpression) {
21452145
// can't use hide with expressionProperties reliably
21462146
var val = model[field.key];
2147-
field.hide = evalCloseToFormlyExpression(field.hideExpression, val, field, index);
2147+
field.hide = evalCloseToFormlyExpression(field.hideExpression, val, field, index, { model: model });
21482148
}
21492149
if (field.extras && field.extras.validateOnModelChange && field.formControl) {
21502150
if (_angularFix2['default'].isArray(field.formControl)) {
@@ -2256,7 +2256,7 @@ return /******/ (function(modules) { // webpackBootstrap
22562256
var model = field.model || $scope.model;
22572257
$scope.$watch(function hideExpressionWatcher() {
22582258
var val = model[field.key];
2259-
return evalCloseToFormlyExpression(field.hideExpression, val, field, index);
2259+
return evalCloseToFormlyExpression(field.hideExpression, val, field, index, { model: model });
22602260
}, function (hide) {
22612261
return field.hide = hide;
22622262
}, true);
@@ -2281,9 +2281,8 @@ return /******/ (function(modules) { // webpackBootstrap
22812281
return field.model = model;
22822282
});
22832283
})();
2284-
} else if (!field.model) {
2285-
field.model = $scope.model;
22862284
}
2285+
22872286
return isNewModel;
22882287

22892288
function resolveStringModel(expression) {

dist/formly.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/formly.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-formly",
3-
"version": "8.0.3",
3+
"version": "8.0.4",
44
"author": "Astrism <[email protected]>",
55
"contributors": [
66
"Astrism <[email protected]>",

src/directives/formly-form.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function formlyForm(formlyUsability, formlyWarn, $parse, formlyConfig, $interpol
4242
${getHideDirective()}="!field.hide"
4343
class="formly-field"
4444
options="field"
45-
model="field.model"
45+
model="field.model || model"
4646
original-model="model"
4747
fields="fields"
4848
form="theFormlyForm"
@@ -140,7 +140,7 @@ function formlyForm(formlyUsability, formlyWarn, $parse, formlyConfig, $interpol
140140
const promise = field.runExpressions && field.runExpressions()
141141
if (field.hideExpression) { // can't use hide with expressionProperties reliably
142142
const val = model[field.key]
143-
field.hide = evalCloseToFormlyExpression(field.hideExpression, val, field, index)
143+
field.hide = evalCloseToFormlyExpression(field.hideExpression, val, field, index, {model})
144144
}
145145
if (field.extras && field.extras.validateOnModelChange && field.formControl) {
146146
if (angular.isArray(field.formControl)) {
@@ -261,7 +261,7 @@ function formlyForm(formlyUsability, formlyWarn, $parse, formlyConfig, $interpol
261261
const model = field.model || $scope.model
262262
$scope.$watch(function hideExpressionWatcher() {
263263
const val = model[field.key]
264-
return evalCloseToFormlyExpression(field.hideExpression, val, field, index)
264+
return evalCloseToFormlyExpression(field.hideExpression, val, field, index, {model})
265265
}, (hide) => field.hide = hide, true)
266266
}
267267
}
@@ -277,9 +277,8 @@ function formlyForm(formlyUsability, formlyWarn, $parse, formlyConfig, $interpol
277277
field.model = resolveStringModel(expression)
278278

279279
$scope.$watch(() => resolveStringModel(expression), (model) => field.model = model)
280-
} else if (!field.model) {
281-
field.model = $scope.model
282280
}
281+
283282
return isNewModel
284283

285284
function resolveStringModel(expression) {

src/directives/formly-form.test.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ describe('formly-form', () => {
445445
{template: input, key: 'foo', model: scope.fieldModel1},
446446
{template: input, key: 'bar', model: scope.fieldModel1},
447447
{template: input, key: 'zoo', model: scope.fieldModel1},
448+
{template: input, key: 'test'},
448449
]
449450
})
450451

@@ -462,6 +463,21 @@ describe('formly-form', () => {
462463
expect(spy1).to.have.been.calledOnce
463464
expect(spy2).to.have.been.calledOnce
464465
})
466+
467+
it('should be updated when the reference to the model changes', () => {
468+
scope.model = {test: 'bar'}
469+
scope.fields[3].expressionProperties = {'data.test': 'model.test'}
470+
471+
compileAndDigest()
472+
$timeout.flush()
473+
474+
scope.model = {test: 'baz'}
475+
476+
scope.$digest()
477+
$timeout.flush()
478+
479+
expect(scope.fields[3].data.test).to.equal('baz')
480+
})
465481
})
466482

467483
describe('nested model as string', () => {
@@ -498,6 +514,7 @@ describe('formly-form', () => {
498514
it('should be updated when the reference to the outer model changes', () => {
499515
scope.model.nested.foo = 'bar'
500516
scope.fields[0].model = 'model.nested'
517+
scope.fields[0].expressionProperties = {'data.foo': 'model.foo'}
501518

502519
compileAndDigest()
503520
$timeout.flush()
@@ -509,8 +526,9 @@ describe('formly-form', () => {
509526
}
510527

511528
scope.$digest()
529+
$timeout.flush()
512530

513-
expect(scope.fields[0].model.foo).to.equal('baz')
531+
expect(scope.fields[0].data.foo).to.equal('baz')
514532
})
515533

516534
function testModelAccessor(accessor) {

0 commit comments

Comments
 (0)