Skip to content
Permalink
Browse files

Question #160 Testing ng-model-options getterSetter

  • Loading branch information
ruhley committed Aug 1, 2017
1 parent d279ed2 commit 08535af2fcdf58e7b48bdccdb23fcb1372bd5a92
Showing with 51 additions and 0 deletions.
  1. +23 −0 examples/02-app.js
  2. +28 −0 examples/02-getterSetter.html
@@ -0,0 +1,23 @@
angular
.module('app', ['color.picker'])
.controller('AppCtrl', function($scope) {
$scope.eventApi = {
onChange: function() {
console.log($scope.color);
},
onBlur: function() {
console.log($scope.color);
},
onOpen: function() {
console.log($scope.color);
},
onClose: function() {
console.log($scope.color);
},
};

var _color = 'hsl(0, 100%, 50%)';
$scope.color = function(newColor) {
return angular.isDefined(newColor) ? (_color = newColor) : _color;
};
});
@@ -0,0 +1,28 @@
<html>
<head>
<title>Example 2 - Getter Setter</title>

<meta http-equiv="X-UA-Compatible" content="IE=Edge" />

<link rel="stylesheet" href="../dist/angularjs-color-picker.min.css" />

<script src="../bower_components/angular/angular.min.js"></script>
<script src="../bower_components/tinycolor/dist/tinycolor-min.js"></script>

<script src="../dist/angularjs-color-picker.js"></script>

<script src="02-app.js"></script>
</head>
<body ng-app="app" ng-controller="AppCtrl">
<div class="col-sm-12">
<h1>AngularJS Color Picker</h1>
<p>An AngularJS directive for a color picker. No requirement on jQuery.</p>
{{color}}
<color-picker
ng-model="color"
ng-model-options="{ getterSetter: true }"
event-api="eventApi"
></color-picker>
</div>
</body>
</html>

0 comments on commit 08535af

Please sign in to comment.
You can’t perform that action at this time.