Skip to content

Commit 276f9fa

Browse files
committed
Bug #31 - $setDirty is not a function in AngularJS <v1.3.4
1 parent 7b4e013 commit 276f9fa

File tree

2 files changed

+101
-1
lines changed

2 files changed

+101
-1
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<html>
2+
<head>
3+
<title>Example 2 - Testing Lib With AngularJS v1.3</title>
4+
5+
<link rel="stylesheet" href="../bower_components/bootstrap/dist/css/bootstrap.min.css" />
6+
7+
<link rel="stylesheet/less" href="../lib/styles/angularjs-color-picker.less" />
8+
<script src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.4.0/less.min.js"></script>
9+
10+
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.3/angular.min.js"></script>
11+
<script src="../bower_components/tinycolor/tinycolor.js"></script>
12+
13+
<script src="../lib/scripts/module.js"></script>
14+
<script src="../lib/scripts/directive.js"></script>
15+
<script src="../lib/scripts/template.js"></script>
16+
17+
<script src="app.js"></script>
18+
</head>
19+
<body ng-app="app" ng-controller="AppCtrl">
20+
<div class="col-sm-12">
21+
<h1>AngularJS Color Picker</h1>
22+
<p>An AngularJS directive for a color picker. No requirement on jQuery.</p>
23+
<form class="col-sm-12">
24+
<div class="row">
25+
<label class="control-label">Format (format)</label>
26+
<select ng-model="format" class="form-control" ng-options="option.value as option.label for option in formatOptions"></select>
27+
</div>
28+
29+
<div class="row">
30+
<label class="control-label">Alpha (alpha) - whether or not to display the alpha control</label>
31+
<select ng-model="alpha" class="form-control" ng-options="option.value as option.label for option in boolOptions"></select>
32+
</div>
33+
34+
<div class="row">
35+
<label class="control-label">Swatch (swatch) - whether or not to display the swatch inside the input field</label>
36+
<select ng-model="swatch" class="form-control" ng-options="option.value as option.label for option in boolOptions"></select>
37+
</div>
38+
39+
<div class="row">
40+
<label class="control-label">Swatch Only (swatch-only) - whether or not to display the input field</label>
41+
<select ng-model="swatchOnly" class="form-control" ng-options="option.value as option.label for option in boolOptions"></select>
42+
</div>
43+
44+
<div class="row">
45+
<label class="control-label">Swatch Position (swatch-pos) - the position of the swatch in the input field - 'left' or 'right'</label>
46+
<select ng-model="swatchPos" class="form-control" ng-options="option.value as option.label for option in swatchPosOptions"></select>
47+
</div>
48+
49+
<div class="row">
50+
<label class="control-label">Swatch Bootstrap Add On (swatch-bootstrap) - whether or not the swatch should appear as a bootstrap add on</label>
51+
<select ng-model="swatchBootstrap" class="form-control" ng-options="option.value as option.label for option in boolOptions"></select>
52+
</div>
53+
54+
<div class="row">
55+
<label class="control-label">Position (pos) - the position of the picker control in relation to the input field - 'bottom left', 'bottom right', 'top left', 'top right'</label>
56+
<select ng-model="pos" class="form-control" ng-options="option.value as option.label for option in posOptions"></select>
57+
</div>
58+
59+
<div class="row">
60+
<label class="control-label">Case (case) - The case of hex colors - 'upper', 'lower'</label>
61+
<select ng-model="case" class="form-control" ng-options="option.value as option.label for option in caseOptions"></select>
62+
</div>
63+
64+
<div class="row">
65+
<label class="control-label">Color</label>
66+
<color-picker
67+
ng-model="color"
68+
color-picker-format="format"
69+
color-picker-alpha="alpha"
70+
color-picker-swatch="swatch"
71+
color-picker-swatch-pos="swatchPos"
72+
color-picker-swatch-bootstrap="swatchBootstrap"
73+
color-picker-pos="pos"
74+
color-picker-case="case"
75+
color-picker-swatch-only="swatchOnly">
76+
</color-picker>
77+
78+
<button class="btn btn-primary" ng-click="color = null;">Clear</button>
79+
</div>
80+
81+
<div class="row">
82+
Two Way Binding
83+
<!-- <color-picker ng-model="color"></color-picker> -->
84+
{{color}}
85+
</div>
86+
87+
<div class="row">
88+
<h2>No Options</h2>
89+
<label class="control-label">Color</label>
90+
<color-picker ng-model="color2"></color-picker>
91+
</div>
92+
93+
<div class="row">
94+
Two Way Binding
95+
{{color2}}
96+
</div>
97+
</form>
98+
</div>
99+
</body>
100+
</html>

lib/scripts/directive.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@
155155

156156
control[0].$setValidity(attrs.name, $scope.isValid);
157157

158-
if (oldValue !== undefined) {
158+
if (oldValue !== undefined && typeof control[0].$setDirty === 'function') {
159159
control[0].$setDirty();
160160
}
161161
} else {

0 commit comments

Comments
 (0)