public marType;
ngDoCheck() {
console.log('translated', this.marType);
}
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("elements", "1", {
packages: "transliteration"
});
function onLoad() {
var options = {
sourceLanguage: google.elements.transliteration.LanguageCode.ENGLISH,
destinationLanguage: [google.elements.transliteration.LanguageCode.MARATHI],
shortcutKey: 'ctrl+g',
transliterationEnabled: true
};
var control = new google.elements.transliteration.TransliterationControl(options);
//control.makeTransliteratable(['firstName']);
var elements = document.getElementsByClassName('marathi');
control.makeTransliteratable(elements);
}
google.setOnLoadCallback(onLoad);
</script>
<textarea class="form-control marathi" placeholder="Type here..." rows="5" name="marType" [(ngModel)]="marType" id="marType"></textarea>
您好,我想实现谷歌输入工具,以限制用户键入本地语言 . 有时它工作正常,但问题是当我访问变量值时,它不会在第一个空格点击中转换输入 . 用户需要按两次空格键或用户必须按任何其他键,如退格键等,然后只有我可以获得输入字段的翻译值 . 我找不到确切的问题 . 提前致谢