[英]Wrap Kendo UI into a Angular 2 component
我正在嘗試將常規Kendo UI小部件(編輯器)包裝放入Angular 2組件。 這可能嗎。 有人做過嗎?
我知道Kendo UI 2 for Angular套件,並且已經在使用它,但是想知道丟失的小部件是否仍可用於Angular 2。
謝謝
因此,這是我的操作方式:
首先,我將jQuery包含在Index.html中。 我使用了CDN鏈接。
然后,我得到了所需的Kendo UI腳本。 我使用http://www.telerik.com/download/custom-download創建了一個較小的文件。
import { Component, Input, Output, EventEmitter, ElementRef, AfterViewInit } from '@angular/core'; declare var $: any; //inject jQuery @Component({ moduleId: module.id, selector: 'editor', template: ` <textarea>{{ text }}</textarea> `, }) export class EditorComponent { @Input() text: string; @Output() onTextChanged = new EventEmitter<string>(); constructor(private elem: ElementRef) { } ngAfterViewInit() { var ta = this.elem.nativeElement.children[0]; var self = this; $(ta).kendoEditor({ tools: [ "bold", "italic", "underline", "strikethrough", "justifyLeft", "justifyCenter", "justifyRight", "justifyFull", "insertUnorderedList", "insertOrderedList", "indent", "outdent", "createLink", "unlink", "insertImage" ], change: function () { self.onTextChanged.emit(this.value()); } }); } }
<editor [text]="'Hello from the outside'" (onTextChanged)="editorTextChanged($event)" ></editor>
我知道這不完全是Angular的方法,但是它可以工作。 如果有人有更好的方法,請在這里分享。
謝謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.