Skip to content
This repository has been archived by the owner on Feb 22, 2018. It is now read-only.

Commit

Permalink
fix(form example): watched collections can not be mutated
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb authored and jbdeboer committed Aug 25, 2014
1 parent e5584e1 commit d39e62a
Showing 1 changed file with 21 additions and 19 deletions.
40 changes: 21 additions & 19 deletions example/web/forms/form.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,33 @@ class FormCtrl {
static const String COLOR_RGB = "rgb";
static const String COLOR_NAME = "name";

static const _COLOR_TYPES = const [COLOR_RGB, COLOR_HSL, COLOR_HEX, COLOR_NAME];

static const _RESOLUTIONS = const ['1024x600',
'1280x800',
'1366x768',
'1440x900',
'1600x900',
'1680x1050',
'1920x1080',
'1920x1200',
'2560x1440',
'2560x1600'];

Scope scope;
NgForm form;
List colors = [];
List lastFormattedColors = [];
final List colors = [];
final List formattedColors = [];

FormCtrl(Scope this.scope, NgForm this.form) {
newColor(COLOR_HEX, '#222');
newColor(COLOR_HEX, '#444');
newColor(COLOR_HEX, '#000');
}

get color_types => [COLOR_RGB, COLOR_HSL, COLOR_HEX, COLOR_NAME];
get resolutions => [
'1024x600',
'1280x800',
'1366x768',
'1440x900',
'1600x900',
'1680x1050',
'1920x1080',
'1920x1200',
'2560x1440',
'2560x1600'
];
List<String> get color_types => _COLOR_TYPES;

List<String> get resolutions => _RESOLUTIONS;

submit() {
this.form.reset();
Expand All @@ -56,7 +59,7 @@ class FormCtrl {
}

formatColors() {
var formatted = [];
formattedColors.clear();
colors.forEach((color) {
var value = null;
switch(color['type']) {
Expand Down Expand Up @@ -84,11 +87,10 @@ class FormCtrl {
break;
}
if(value != null) {
formatted.add(value);
formattedColors.add(value);
}
});
lastFormattedColors = formatted;
return formatted;
return formattedColors;
}

newColor([String type = COLOR_HEX, String color]) {
Expand Down

0 comments on commit d39e62a

Please sign in to comment.