From: Coleman Watts Date: Wed, 29 Nov 2017 19:39:41 +0000 (-0500) Subject: CRM-21497 - crmRouteBinder: add deep comparison option X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=284ed4f02e57672dbd92b677ff8c5da1e76cae2f;p=civicrm-core.git CRM-21497 - crmRouteBinder: add deep comparison option --- diff --git a/ang/crmRouteBinder.js b/ang/crmRouteBinder.js index 196fb3eb91..16947a3d79 100644 --- a/ang/crmRouteBinder.js +++ b/ang/crmRouteBinder.js @@ -51,6 +51,9 @@ options.format = options.format || 'json'; var fmt = formats[options.format]; + if (options.deep) { + fmt.watcher = '$watch'; + } if (options.default === undefined) { options.default = fmt.default; } @@ -85,7 +88,7 @@ activeTimer = null; ignorable = {}; }, 50); - }); + }, options.deep); }; return $delegate; diff --git a/ang/crmRouteBinder.md b/ang/crmRouteBinder.md index 37003abebc..a297bdc459 100644 --- a/ang/crmRouteBinder.md +++ b/ang/crmRouteBinder.md @@ -30,16 +30,18 @@ Things to try out: ## Functions - * `$scope.$bindToRoute(options)` - * The `options` object should contain keys: - * `expr` (string): The name of a scoped variable to sync. - * `param` (string): The name of a query-parameter to sync. (If the `param` is included in the URL, it will initialize the expr.) - * `format` (string): The type of data to put in `param`. May be one of: - * `json` (default): The `param` is JSON, and the `expr` is a decoded object. - * `raw`: The `param` is string, and the `expr` is a string. - * `int`: the `param` is an integer-like string, and the expr is an integer. - * `bool`: The `param` is '0'/'1', and the `expr` is false/true. - * `default` (object): The default data. (If the `param` is not included in the URL, it will initialize the expr.) +**`$scope.$bindToRoute(options)`** +*The `options` object should contain keys:* + + * `expr` (string): The name of a scoped variable to sync. + * `param` (string): The name of a query-parameter to sync. (If the `param` is included in the URL, it will initialize the expr.) + * `format` (string): The type of data to put in `param`. May be one of: + * `json` (default): The `param` is JSON, and the `expr` is a decoded object. + * `raw`: The `param` is string, and the `expr` is a string. + * `int`: the `param` is an integer-like string, and the expr is an integer. + * `bool`: The `param` is '0'/'1', and the `expr` is false/true. + * `default` (object): The default data. (If the `param` is not included in the URL, it will initialize the expr.) + * `deep` (boolean): By default the json format will be watched using a shallow comparison. For nested objects and arrays enable this option. ## Suggested Usage