我创建了一个自定义数据类型来处理文本区域的字符限制。
我之前一直在关注$scope的演示。info=“Hello World”,然后用户开始在文本区域键入。
我已经删除了它,所以它应该从本影内容界面中删除此文本。
但它仍然在文本框的右侧显示“Hello World”。
客户编辑角度控制器:
angular.module("umbraco").controller("My.CustomEditorController", function
($scope, notificationsService) {
$scope.info = "";
$scope.limitChars = function () {
var limit = parseInt($scope.model.config.limit);
if ($scope.model.value.length > limit) {
$scope.info = "You cannot write more than " + limit + " characters!";
$scope.model.value = $scope.model.value.substr(0, limit);
notificationsService.remove(0);
notificationsService.warning($scope.info);
}
else {
$scope.info = "You have " + (limit - $scope.model.value.length) + " characters left.";
}
}
});