File tree Expand file tree Collapse file tree 4 files changed +66
-6
lines changed Expand file tree Collapse file tree 4 files changed +66
-6
lines changed Original file line number Diff line number Diff line change 1111 < script src ="../bower_components/angular/angular.min.js "> </ script >
1212 < script src ="../bower_components/tinycolor/dist/tinycolor-min.js "> </ script >
1313
14- < script src ="../dist/angularjs-color-picker .js "> </ script >
14+ < script src ="../src/scripts/module .js " type =" module "> </ script >
1515
1616 < script src ="app.js "> </ script >
1717 </ head >
Original file line number Diff line number Diff line change 1+ angular
2+ . module ( 'app' , [ 'color.picker' ] )
3+ . controller ( 'AppCtrl' , function ( $scope , $timeout ) {
4+ $timeout ( ( ) => {
5+ $scope . color = 'hsl(180, 100%, 50%)' ;
6+ } ) ;
7+ $scope . options = {
8+ close : { show : true } ,
9+ clear : { show : true } ,
10+ reset : { show : true } ,
11+ placeholder : $scope . color
12+ } ;
13+ $scope . api = { } ;
14+
15+ $scope . setValue = function ( value ) {
16+ $scope . color = value ;
17+ } ;
18+ } ) ;
Original file line number Diff line number Diff line change 1+ < html >
2+ < head >
3+ < title > Example 4 - Delayed Initial Value</ title >
4+
5+ < meta http-equiv ="X-UA-Compatible " content ="IE=Edge " />
6+
7+ < link rel ="stylesheet " href ="../dist/angularjs-color-picker.min.css " />
8+ < link rel ="stylesheet " href ="../dist/themes/angularjs-color-picker-bootstrap.min.css " />
9+ < link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css " />
10+
11+ < script src ="../bower_components/angular/angular.min.js "> </ script >
12+ < script src ="../bower_components/tinycolor/dist/tinycolor-min.js "> </ script >
13+
14+ < script src ="../src/scripts/module.js " type ="module "> </ script >
15+
16+ < script src ="04-app.js "> </ script >
17+ </ head >
18+ < body ng-app ="app " ng-controller ="AppCtrl ">
19+ < div class ="col-sm-12 ">
20+ < h1 > AngularJS Color Picker</ h1 >
21+ < p > An AngularJS directive for a color picker. No requirement on jQuery.</ p >
22+ < form class ="col-sm-12 ">
23+
24+ < h3 > Examples</ h3 >
25+
26+ < div class ="row ">
27+ < label class ="control-label "> Color</ label >
28+ < button ng-click ="setValue('#FF0000') "> Set value to #FF0000</ button >
29+ < color-picker
30+ ng-model ="color "
31+ options ="options "
32+ api ="api "
33+ event-api ="eventApi "
34+ > </ color-picker >
35+ </ div >
36+
37+ < div class ="row ">
38+ Two Way Binding
39+ {{color}}
40+ </ div >
41+ </ form >
42+ </ div >
43+ </ body >
44+ </ html >
Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ export default class AngularColorPickerController {
185185 /** Triggered on change to internal or external ngModel value */
186186 watchNgModel ( newValue , oldValue ) {
187187 // set initial value if not already set
188- if ( newValue !== undefined && oldValue !== undefined && ! this . hasOwnProperty ( 'initialNgModel' ) ) {
188+ if ( newValue !== undefined && ! this . hasOwnProperty ( 'initialNgModel' ) ) {
189189 this . initialNgModel = newValue ;
190190 }
191191
@@ -481,11 +481,9 @@ export default class AngularColorPickerController {
481481 } ;
482482
483483 this . api . clear = ( event ) => {
484- if ( this . internalNgModel !== '' ) {
485- this . setNgModel ( '' ) ;
484+ this . setNgModel ( null ) ;
486485
487- this . eventApiDispatch ( 'onClear' , [ event ] ) ;
488- }
486+ this . eventApiDispatch ( 'onClear' , [ event ] ) ;
489487 } ;
490488
491489 this . api . reset = ( event ) => {
You can’t perform that action at this time.
0 commit comments