每当特殊字符输入剑道编辑器并用字段值替换字符时,我都需要加载字段列表。这里我提到我的代码
<textarea kendo-editor k-ng-model="trigger.message " calss = 'message' ng-change = viewList></textarea >
<ul>
<li ng-repeat="option in data" ng-click="setData(option.field_name)">{{option.field_name}}</li>
</ul>
在控制器中:
$scope.viewList = function() {
var templist = []
if ($scope.trigger.message == '' || $scope.trigger.message == undefined) {
templist = [];
} else if ($scope.trigger.message.indexOf('@') > -1) {
templist = $scope.fields;
}
$scope.messageFields = templist;
}
$scope.setData = function(value) {
$scope.trigger.message = $scope.trigger.message.replace('@', '') + " %" + value + "% ";
$scope.messageFields = [];
}
任何人都可以指导我解决这个问题。在此先感谢。