2016-05-03 70 views
1

我也做了以下步驟:NG2-CKEditor的 「CKEDITOR」

  1. 安裝NG2-CKEditor的 -JSPM:JSPM安裝NG2-的CKEditor = github上:chymz/NG2-CKEditor的 -NPM:NPM安裝NG2-CKEditor的
  2. 創建TS文件:

    import {Component} from 'angular2/core'; 
    import {CKEditor} from 'ng2-ckeditor'; 
    
    @Component({ 
        selector: 'sample', 
        directives: [CKEditor], 
        template: ` 
        <ckeditor [(ngModel)]="ckeditorContent" [config]="{uiColor: '#99000'}"></ckeditor>` 
    }) 
    export class Sample{ 
        constructor(){ 
        this.ckeditorContent = `<p>My HTML</p>`; 
        } 
    } 
    

但在運行時我得到一個異常「CKEDITOR未定義」。

我試圖導入「CKEditor的」本身, 但在這種情況下,我有另外一個運行時異常 「的CKEditor遺漏的類型錯誤不能設置屬性‘目錄’未定義的」

感謝。

回答

3

您錯過了一個步驟。您需要在HTML中包含一個指向CKEditor實際源文件的鏈接。去here並選擇一個版本。包括它如下:

<script src="//cdn.ckeditor.com/4.5.8/full/ckeditor.js"></script> 

其餘步驟如您所述。

編輯

在你沒有設置正確SystemJS情況下應該是這個樣子:

System.config({ 
     packages: { 
      "app": { 
       "format": 'register', 
       "defaultExtension": 'js' 
      }, 
      "ng2-ckeditor": { 
       "defaultExtension": "js" 
      } 
     }, 
     map: { 
      "ng2-ckeditor": "node_modules/ng2-ckeditor/lib/CKEditor.js" 
     } 
    }); 
+0

這個是什麼system.config碼的位置? – MohammedAshrafali

相關問題