textbox - Marcura/marcura-ui GitHub Wiki
View:
<ma-text-box
value="address">
</ma-text-box>
Controller:
$scope.address = '34, Bishop Street';
Determines whether the button which allows the user to clear the value is displayed.
Boolean
false
Sets the field:
View:
<ma-text-box
can-reset="true">
</ma-text-box>
A timeout (in milliseconds) after which change
event is invoked. The timeout is reset after another change takes place.
Number
0
Sets the field:
View:
<ma-text-box
change-timeout="500">
</ma-text-box>
Determines whether change
event should fire even when the value is invalid.
Boolean
false
Sets the field:
View:
<ma-text-box
change-when-is-invalid="true">
</ma-text-box>
A number of decimal digits allowed.
Note: type
should be set to number
.
Number
2
Sets the field:
View:
<ma-text-box
decimals="3">
</ma-text-box>
A value to use when the main value of the component is not set.
When the value is reset defaultValue
is used as value.
String
''
Sets the field:
View:
<ma-text-box
type="number"
value="amount"
default-value="0">
</ma-text-box>
Controller:
$scope.amount = undefined;
Determines whether the button which allows the user to show or hide password is displayed.
Boolean
true
Sets the field:
View:
<ma-text-box
has-show-password-button="false">
</ma-text-box>
Unique identifier of the component.
String
''
Sets the field:
View:
<ma-text-box
id="address">
</ma-text-box>
An object that provides API for the component.
View:
<ma-text-box
instance="textBox">
</ma-text-box>
Controller:
$scope.textBox = {};
// API object can be used after the component has been initialized by AngularJS,
// which is often after a timeout or in callback functions.
$timeout(function() {
var isValid = textBox.isValid();
});
Determines whether the component is disabled.
Boolean
false
Sets the field:
View:
<ma-text-box
is-disabled="true">
</ma-text-box>
Determines whether a value is required.
If value is not entered by the user the component will become invalid and will be highlighted accordingly.
Boolean
false
Sets the field:
View:
<ma-text-box
is-required="true">
</ma-text-box>
A maximum number or length of text allowed (inclusive).
Number
null
Sets the field:
View:
<ma-text-box
max="max">
</ma-text-box>
Controller:
$scope.max = 5000.50;
A minimum number or length of text allowed (inclusive).
Number
null
Sets the field:
View:
<ma-text-box
min="min">
</ma-text-box>
Controller:
$scope.min = 1000.50;
Determines whether white spaces are removed from both ends of the value when it is changed.
Boolean
true
Sets the field:
View:
<ma-text-box
trim="false">
</ma-text-box>
Type of the component, which can be text
, password
, email
or number
.
String
'text'
Sets the field:
View:
<ma-text-box
type="password">
</ma-text-box>
Determines whether to format number.
Boolean
true
Sets the field:
View:
<ma-text-box
use-format="false">
</ma-text-box>
A list of validators which is used to validate the value each time it is changed.
Array
null
Sets the field:
View:
<ma-text-box
validators="[addressValidator]">
</ma-text-box>
Controller:
$scope.addressValidator = {
validate: function(port) {
// Check the address somehow and return true or false.
return true;
}
};
A value of the component which is bound to an outer scope with two-way data binding.
String
null
Sets the field:
View:
<ma-text-box
value="address">
</ma-text-box>
Controller:
$scope.address = '34, Bishop Street';
Fires when the component loses focus.
maValue String
Value.
maOldValue String
Value at the moment of receiving focus.
maHasValueChanged Boolean
Determines whether the value has changed since the last time the component received focus.
Subscribes to the event:
View:
<ma-text-box
value="address"
blur="blur(maValue)">
</ma-text-box>
Controller:
$scope.blur = function(address) {
// Handle the event.
};
Fires when the value is changed by the user.
maValue String
Value.
maOldValue String
Old value.
Subscribes to the event:
View:
<ma-text-box
value="address"
change="change(maValue, maOldValue)">
</ma-text-box>
Controller:
$scope.change = function(address) {
// Handle the event.
};
Fires when the component gets focus.
maValue String
Value.
Subscribes to the event:
View:
<ma-text-box
value="address"
focus="focus(maValue)">
</ma-text-box>
Controller:
$scope.focus = function(address) {
// Handle the event.
};
Fires when the value is reset.
Subscribes to the event:
View:
<ma-text-box
reset="reset()">
</ma-text-box>
Controller:
$scope.reset = function() {
// Handle the event.
};
Fires when the value is validated.
maValue String
Value entered by the user.
Subscribes to the event:
View:
<ma-text-box
validate="validate(maValue)">
</ma-text-box>
Controller:
$scope.validate = function(value) {
// Handle the event.
};
Clears the value and sets the component to the initial untouched state.
View:
<ma-text-box
instance="textBox">
</ma-text-box>
Controller:
$scope.textBox = {};
$timeout(function() {
textBox.clear();
}, 5000);
Returns a validator which has not passed the validation.
View:
<ma-text-box
instance="textBox">
</ma-text-box>
Controller:
$scope.textBox = {};
$timeout(function() {
var failedValidator = textBox.failedValidator();
}, 5000);
Sets focus on the component.
View:
<ma-text-box
instance="textBox">
</ma-text-box>
Controller:
$scope.textBox = {};
$timeout(function() {
textBox.focus();
}, 5000);
Determines whether the component is initialized.
View:
<ma-text-box
instance="textBox">
</ma-text-box>
Controller:
$scope.textBox = {};
$timeout(function() {
var isInitialized = textBox.isInitialized;
}, 5000);
Determines whether the value of the component is valid.
View:
<ma-text-box
instance="textBox">
</ma-text-box>
Controller:
$scope.textBox = {};
$timeout(function() {
var isValid = textBox.isValid();
}, 5000);
Determines whether the user has interacted with the component.
View:
<ma-text-box
instance="textBox">
</ma-text-box>
Controller:
$scope.textBox = {};
$timeout(function() {
var isTouched = textBox.isTouched();
}, 5000);
Validates the value and highlights the component accordingly.
View:
<ma-text-box
instance="textBox">
</ma-text-box>
Controller:
$scope.textBox = {};
$timeout(function() {
textBox.validate();
}, 5000);