<span
inline-edit="myModel"
inline-edit-validation="myValidator(newValue)"
inline-edit-on-blur="cancel"></span>
$scope.myModel = 'An editable text';
$scope.myValidator = function(newValue) {
// a simple required field:
return !!newValue;
};
.ng-inline-edit__input {
border-bottom: 1px dashed #333;
}
.ng-inline-edit--error .ng-inline-edit__input {
border-color: #f00;
}
.ng-inline-edit__button {
color: #00f;
margin-left: 5px;
}
.ng-inline-edit__button:hover {
text-decoration: underline;
}
<span
inline-edit="myModel"
inline-edit-callback="myUpdateHandler(newValue)"
inline-edit-placeholder="Type your value here"
inline-edit-btn-edit=""
inline-edit-on-blur="save"
inline-edit-on-click></span>
$scope.myModel = 'Click here and delete me';
$scope.myUpdateHandler = function(newValue) {
// check your console
console.log('value of your model is now: ' + newValue);
};
.ng-inline-edit__input {
padding: 0 3px;
}
.ng-inline-edit__text {
padding: 2px 3px;
font-weight: bold;
}
.ng-inline-edit__text:hover {
background: #ff0;
border-radius: 4px;
}
.ng-inline-edit__text--placeholder {
color: #999;
font-weight: normal;
font-style: italic;
}
<span
inline-edit="myModel"
inline-edit-validation="validateOnServer(newValue)"
inline-edit-btn-save="Save"
inline-edit-btn-cancel="Cancel"></span>
$scope.myModel = 'Need more than 10 chars',
$scope.validateOnServer = function(newValue) {
var defer = $q.defer();
// a fake server validation:
$timeout(function() {
if (newValue.length > 10) { // should be more than 10 chars
defer.resolve();
} else {
defer.reject();
}
}, 2500);
return defer.promise;
};
.ng-inline-edit--validating:after {
content: "";
display: inline-block;
width: 16px;
height: 16px;
background: url(ajax-loader.gif);
}
.ng-inline-edit--validating .ng-inline-edit__input {
background: #fff;
opacity: .4;
}
.ng-inline-edit--error .ng-inline-edit__input {
color: #f00;
}
.ng-inline-edit__button {
font-size: 0;
margin-left: 5px;
visibility: hidden;
opacity: .6;
}
.ng-inline-edit__button:hover {
opacity: 1;
}
.ng-inline-edit:hover .ng-inline-edit__button,
.ng-inline-edit .ng-inline-edit__button--save,
.ng-inline-edit .ng-inline-edit__button--cancel {
visibility: visible;
}
.ng-inline-edit__button:after {
font-size: 24px;
line-height: 24px;
}
.ng-inline-edit__button--edit:after {
content: "\270E";
color: #00f;
}
.ng-inline-edit__button--save:after {
content: "\2714";
color: #0f0;
}
.ng-inline-edit__button--cancel:after {
content: "\2716";
color: #f00;
}
<span
inline-edit="myModel"
inline-edit-validation="myValidator(newValue)"
inline-edit-filter="currency"
inline-edit-on-blur="cancel"></span>
$scope.myModel = 1250000;
$scope.myValidator = function(newValue) {
return !isNaN(newValue);
};
.ng-inline-edit__input {
border-bottom: 1px dashed #333;
}
.ng-inline-edit--error .ng-inline-edit__input {
border-color: #f00;
}
.ng-inline-edit__button {
color: #00f;
margin-left: 5px;
}