fix(checkbox): prefix true-value & false-value with ng:

This commit is contained in:
Igor Minar 2011-10-13 16:58:44 -07:00
parent d0425de29e
commit d83a92c121
2 changed files with 10 additions and 10 deletions

View file

@ -414,8 +414,8 @@ angularInputType('integer', numericRegexpInputType(INTEGER_REGEXP, 'INTEGER'));
*
* @param {string} ng:model Assignable angular expression to data-bind to.
* @param {string=} name Property name of the form under which the widgets is published.
* @param {string=} true-value The value to which the expression should be set when selected.
* @param {string=} false-value The value to which the expression should be set when not selected.
* @param {string=} ng:true-value The value to which the expression should be set when selected.
* @param {string=} ng:false-value The value to which the expression should be set when not selected.
* @param {string=} ng:change Angular expression to be executed when input changes due to user
* interaction with the input element.
*
@ -432,7 +432,7 @@ angularInputType('integer', numericRegexpInputType(INTEGER_REGEXP, 'INTEGER'));
<form name="myForm">
Value1: <input type="checkbox" ng:model="value1"> <br/>
Value2: <input type="checkbox" ng:model="value2"
true-value="YES" false-value="NO"> <br/>
ng:true-value="YES" ng:false-value="NO"> <br/>
</form>
<tt>value1 = {{value1}}</tt><br/>
<tt>value2 = {{value2}}</tt><br/>
@ -453,8 +453,8 @@ angularInputType('integer', numericRegexpInputType(INTEGER_REGEXP, 'INTEGER'));
*/
angularInputType('checkbox', function(inputElement) {
var widget = this,
trueValue = inputElement.attr('true-value'),
falseValue = inputElement.attr('false-value');
trueValue = inputElement.attr('ng:true-value'),
falseValue = inputElement.attr('ng:false-value');
if (!isString(trueValue)) trueValue = true;
if (!isString(falseValue)) falseValue = false;

View file

@ -256,13 +256,13 @@ describe('widget: input', function() {
it('should allow custom enumeration', function() {
compile('<input type="checkbox" ng:model="name" true-value="ano" false-value="nie"/>');
compile('<input type="checkbox" ng:model="name" ng:true-value="y" ng:false-value="n">');
scope.name='ano';
scope.name='y';
scope.$digest();
expect(scope.$element[0].checked).toBe(true);
scope.name='nie';
scope.name='n';
scope.$digest();
expect(scope.$element[0].checked).toBe(false);
@ -271,10 +271,10 @@ describe('widget: input', function() {
expect(scope.$element[0].checked).toBe(false);
browserTrigger(element);
expect(scope.name).toEqual('ano');
expect(scope.name).toEqual('y');
browserTrigger(element);
expect(scope.name).toEqual('nie');
expect(scope.name).toEqual('n');
});