2016-08-09 61 views

回答

1

我想出瞭解決方案,使用angular的$ compile將角度指令呈現爲html。

代碼:

CategoryEditor.prototype.init = function (params) { 
    this.container = document.createElement('div'); 
    this.container.tabIndex = "0"; 

    this.dropdown = document.createElement('div'); 
    this.dropdown.setAttribute("dynamic", "html"); 
    this.container.appendChild(this.dropdown); 
    //My directive is of the form <div dynamic="html"></div> 

    var that = this; 
    $scope.selectedCallback = function ($item) { 
    that.selectCategory($item); 
    params.stopEditing(); 
    }; 
    $compile(this.container)($scope); 
    $scope.$digest(); 
}; 
1

請確保您有angularCompileRows = true來獲得角1 AG-電網

+0

只是沒有奏效內工作。我不得不使用$ compile來使它起作用。 – Karthik

+0

這種方法適用於我 – Barif