동적으로 대문자를 입력 할 때 문제가 있습니다. 내 코드에서 어떤 글자를 대문자로 쓸 수 있지만 동적 인 것은 아닙니다. 이에 대한 해결책이 있다면 알려주세요. 여기 내 코드 :어떻게 문자를 대문자로 대문자로 쓸 수 있습니까?
이것은 내 컨트롤러입니다. 이 솔루션은 어떻게 든 도와, 또는 나에게 어떻게 할 수있는 논리를 말할 알고있는 경우
return {
priority: 100,
require: 'ngModel',
restrict: 'A',
link: function (scope, iElement, iAttrs, controller) {
controller.$parsers.push(function (inputValue) {
var transformedInput = '';
if(inputValue){
for(var i=0; i<inputValue.length; i++){
if(i===0 || i===5){
transformedInput += inputValue.charAt(i).toUpperCase();
}
else{
transformedInput += inputValue.charAt(i).toLowerCase();
}
}
}
if (transformedInput != inputValue) {
controller.$setViewValue(transformedInput);
controller.$render();
}
return transformedInput;
});
및 index.html을
<textarea id="fieldId" class="textarea" style="resize: none" cols="30" row="2" ui-mask="{{typetext}}" ng-model="model" data-ng-trim="fasle" ng-trim="false" ng-focus="expression">
: 내가 어떤 문자로 활용할 수 있도록
app.controller('myController', ['$scope', '$document',function($scope, $document) {
$scope.typetext = "I am Programmer";
$document.on('keydown', function(e) {
if (e.which === 8 && e.target.nodeName !== "INPUT") {
e.preventDefault();
}
});
}
이것은 가능한 경우 대문자를 동적으로 만듭니다.
미리 감사드립니다.
당신은 "동적"아니다 무엇을 의미합니까? 예상 및 실제 결과는 무엇입니까? – Fissio
잘 프로그래머입니다. 나는 데이터베이스에서 오는 모든 단어에 대해 작동하도록하고 싶습니다. 가능하다면. 나는 그것이 데이터베이스에서 오는 단어와 비교하여 자본화한다고 생각합니다. 예를 들어 어떤 사람들이 "우리가 온다 ...."라고 입력하면 W와 M을 대문자로 사용하고 결과는 W가됩니다. – brithwulf