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

Commit 2cb7d2e

Browse files
author
Kent C. Dodds
committed
6.22.0
1 parent 7593a8a commit 2cb7d2e

File tree

4 files changed

+43
-20
lines changed

4 files changed

+43
-20
lines changed

dist/formly.js

Lines changed: 38 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! angular-formly version 6.21.1 built with ♥ by Astrism <[email protected]>, Kent C. Dodds <[email protected]> (ó ì_í)=óò=(ì_í ò)
1+
//! angular-formly version 6.22.0 built with ♥ by Astrism <[email protected]>, Kent C. Dodds <[email protected]> (ó ì_í)=óò=(ì_í ò)
22

33
(function webpackUniversalModuleDefinition(root, factory) {
44
if(typeof exports === 'object' && typeof module === 'object')
@@ -147,7 +147,7 @@ return /******/ (function(modules) { // webpackBootstrap
147147

148148
ngModule.constant('formlyApiCheck', _providersFormlyApiCheck2['default']);
149149
ngModule.constant('formlyErrorAndWarningsUrlPrefix', _otherDocsBaseUrl2['default']);
150-
ngModule.constant('formlyVersion', ("6.21.1")); // <-- webpack variable
150+
ngModule.constant('formlyVersion', ("6.22.0")); // <-- webpack variable
151151

152152
ngModule.provider('formlyUsability', _providersFormlyUsability2['default']);
153153
ngModule.provider('formlyConfig', _providersFormlyConfig2['default']);
@@ -328,6 +328,9 @@ return /******/ (function(modules) { // webpackBootstrap
328328
id: apiCheck.string.optional,
329329
name: apiCheck.string.optional,
330330
expressionProperties: expressionProperties.optional,
331+
extras: apiCheck.shape({
332+
validateOnModelChange: apiCheck.bool.optional
333+
}).strict.optional,
331334
data: apiCheck.object.optional,
332335
templateOptions: apiCheck.object.optional,
333336
wrapper: specifyWrapperType.optional,
@@ -445,7 +448,7 @@ return /******/ (function(modules) { // webpackBootstrap
445448
Object.defineProperty(exports, "__esModule", {
446449
value: true
447450
});
448-
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("6.21.1") + "/other/ERRORS_AND_WARNINGS.md#";
451+
exports["default"] = "https://github.com/formly-js/angular-formly/blob/" + ("6.22.0") + "/other/ERRORS_AND_WARNINGS.md#";
449452
module.exports = exports["default"];
450453

451454
/***/ },
@@ -1248,6 +1251,7 @@ return /******/ (function(modules) { // webpackBootstrap
12481251
return {
12491252
restrict: 'AE',
12501253
transclude: true,
1254+
require: '?^formlyForm',
12511255
scope: {
12521256
options: '=',
12531257
model: '=',
@@ -1282,7 +1286,6 @@ return /******/ (function(modules) { // webpackBootstrap
12821286
setDefaultValue();
12831287
setInitialValue();
12841288
runExpressions();
1285-
addModelWatcher($scope, $scope.options);
12861289
addValidationMessages($scope.options);
12871290
invokeControllers($scope, $scope.options, fieldType);
12881291

@@ -1315,6 +1318,7 @@ return /******/ (function(modules) { // webpackBootstrap
13151318
function simplifyLife(options) {
13161319
// add a few empty objects (if they don't already exist) so you don't have to undefined check everywhere
13171320
formlyUtil.reverseDeepMerge(options, {
1321+
extras: {},
13181322
data: {},
13191323
templateOptions: {},
13201324
validation: {}
@@ -1377,13 +1381,6 @@ return /******/ (function(modules) { // webpackBootstrap
13771381
});
13781382
}
13791383

1380-
// initialization functions
1381-
function addModelWatcher(scope, options) {
1382-
if (options.model) {
1383-
scope.$watch('options.model', runExpressions, true);
1384-
}
1385-
}
1386-
13871384
function resetModel() {
13881385
$scope.model[$scope.options.key] = $scope.options.initialValue;
13891386
if ($scope.options.formControl) {
@@ -1445,12 +1442,19 @@ return /******/ (function(modules) { // webpackBootstrap
14451442
}
14461443

14471444
// link function
1448-
function fieldLink(scope, el) {
1445+
function fieldLink(scope, el, attrs, formlyFormCtrl) {
14491446
if (scope.options.fieldGroup) {
14501447
setFieldGroupTemplate();
14511448
return;
14521449
}
14531450

1451+
// watch the field model (if exists) if there is no parent formly-form directive (that would watch it instead)
1452+
if (!formlyFormCtrl && scope.options.model) {
1453+
scope.$watch('options.model', function () {
1454+
return scope.options.runExpressions();
1455+
}, true);
1456+
}
1457+
14541458
addAttributes();
14551459
addClasses();
14561460

@@ -2080,14 +2084,16 @@ return /******/ (function(modules) { // webpackBootstrap
20802084

20812085
function onModelOrFormStateChange() {
20822086
_angularFix2['default'].forEach($scope.fields, function runFieldExpressionProperties(field, index) {
2083-
/*jshint -W030 */
20842087
var model = field.model || $scope.model;
2085-
field.runExpressions && field.runExpressions(model);
2088+
field.runExpressions && field.runExpressions();
20862089
if (field.hideExpression) {
20872090
// can't use hide with expressionProperties reliably
20882091
var val = model[field.key];
20892092
field.hide = evalCloseToFormlyExpression(field.hideExpression, val, field, index);
20902093
}
2094+
if (field.extras && field.extras.validateOnModelChange && field.formControl) {
2095+
field.formControl.$validate();
2096+
}
20912097
});
20922098
}
20932099

@@ -2102,7 +2108,8 @@ return /******/ (function(modules) { // webpackBootstrap
21022108
}
21032109
}
21042110

2105-
_angularFix2['default'].forEach($scope.fields, initModel); // initializes the model property if set to 'formState'
2111+
setupModels();
2112+
21062113
_angularFix2['default'].forEach($scope.fields, attachKey); // attaches a key based on the index if a key isn't specified
21072114
_angularFix2['default'].forEach($scope.fields, setupWatchers); // setup watchers for all fields
21082115
}
@@ -2138,6 +2145,22 @@ return /******/ (function(modules) { // webpackBootstrap
21382145
});
21392146
}
21402147

2148+
function setupModels() {
2149+
// a set of field models that are already watched (the $scope.model will have its own watcher)
2150+
var watchedModels = [$scope.model];
2151+
2152+
_angularFix2['default'].forEach($scope.fields, function (field) {
2153+
initModel(field);
2154+
2155+
if (field.model && watchedModels.indexOf(field.model) === -1) {
2156+
$scope.$watch(function () {
2157+
return field.model;
2158+
}, onModelOrFormStateChange, true);
2159+
watchedModels.push(field.model);
2160+
}
2161+
});
2162+
}
2163+
21412164
function initModel(field) {
21422165
if (_angularFix2['default'].isString(field.model)) {
21432166
var expression = field.model;

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": "6.21.1",
3+
"version": "6.22.0",
44
"author": "Astrism <[email protected]>",
55
"contributors": [
66
"Astrism <[email protected]>",

0 commit comments

Comments
 (0)