Skip to content

Commit 31baa5d

Browse files
committed
Change a watch to watchCollection
The data should be an array so watchCollection should be used on the list provider.
1 parent f5f4ca7 commit 31baa5d

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,10 @@ Below is an example. The variables use model.variable at the moment, considering
8282
}
8383
```
8484

85-
**Local Data**
85+
**Local Data** must be an array of strings for now.
86+
8687
Within the schema form controller:
88+
8789
```javascript
8890
$scope.cities = [ 'Melbourne', 'Toronto', 'London' ]
8991
```
@@ -96,14 +98,14 @@ Within the form definition:
9698
},
9799
```
98100

99-
The loaded data must be in one of the following two formats:
101+
**Remotely** loaded data must be in one of the following two formats:
100102

101103
**enum**
102104
```javascript
103105
{
104106
"title":"Suburb",
105107
"description":"Suburbs for Melbourne, Victoria",
106-
"enum":["Hawthorn","Melbourne","Richmond"]
108+
"enum":[ "Hawthorn", "Melbourne", "Richmond" ]
107109
}
108110
```
109111
**titleMap**
@@ -112,10 +114,10 @@ The loaded data must be in one of the following two formats:
112114
"title":"Suburb",
113115
"description":"Suburbs for Melbourne, Victoria",
114116
"titleMap":[
115-
{"name":"Hawthorn", "value":"Hawthorn"},
116-
{"name":"Melbourne", "value":"Melbourne"},
117+
{"name": "Hawthorn", "value": "Hawthorn"},
118+
{"name": "Melbourne", "value": "Melbourne"},
117119
...
118-
{"name":"Richmond", "value":"Richmond"}
120+
{"name": "Richmond", "value": "Richmond"}
119121
]
120122
}
121123
```

bootstrap-external-options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ angular.module('schemaForm').directive('externalOptions', function() {
8383
};
8484

8585
if (!!scope.form.optionData) {
86-
scope.$parent.evalExpr('this').$watch(scope.form.optionData, function(newOptions, oldOptions) {
86+
scope.$parent.evalExpr('this').$watchCollection(scope.form.optionData, function(newOptions, oldOptions) {
8787
var options = {};
8888
if (angular.isArray(newOptions) && newOptions.length) {
8989
options = (angular.isString(newOptions[0])) ? { enum: newOptions } : { titleMap: newOptions };

bootstrap-external-options.min.js

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

src/angular-external-options.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ angular.module('schemaForm').directive('externalOptions', function() {
8282
};
8383

8484
if (!!scope.form.optionData) {
85-
scope.$parent.evalExpr('this').$watch(scope.form.optionData, function(newOptions, oldOptions) {
85+
scope.$parent.evalExpr('this').$watchCollection(scope.form.optionData, function(newOptions, oldOptions) {
8686
var options = {};
8787
if (angular.isArray(newOptions) && newOptions.length) {
8888
options = (angular.isString(newOptions[0])) ? { enum: newOptions } : { titleMap: newOptions };

0 commit comments

Comments
 (0)