Skip to content

Commit

Permalink
Merge pull request civicrm#11345 from colemanw/CRM-21497
Browse files Browse the repository at this point in the history
CRM-21497 - crmRouteBinder: add deep comparison option
  • Loading branch information
colemanw authored and sluc23 committed Jan 10, 2018
2 parents 20284b7 + ff0937a commit 17f7215
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
5 changes: 4 additions & 1 deletion ang/crmRouteBinder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -85,7 +88,7 @@
activeTimer = null;
ignorable = {};
}, 50);
});
}, options.deep);
};

return $delegate;
Expand Down
22 changes: 12 additions & 10 deletions ang/crmRouteBinder.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 17f7215

Please sign in to comment.