2016-11-17 30 views
3

我正在使用textAngular Wysiwyg /文本編輯器和@mentio庫,當我在一個HTML頁面中使用指令多於一個導致問題。我試圖使用上下文編輯器提ID還是沒能解決問題無法在'Range'上執行'setStart':在頁面中使用@enntio時,參數1不是'Node'類型的問題?

<mentio-menu mentio-for="'content-editor-{{$id}}'" 
     mentio-trigger-char="'@'" 
     mentio-items="people" 
     mentio-template-url="/iterator.tpl" 
     mentio-search="searchPeople(term)" 
     mentio-select="getPeopleText(item)"> 

var directiveDefinitionObject = { 
     restrict: 'E', 
     templateUrl: "app/partials/textAngular-mention-template/replyTextAngularWithMentio.html", 
     require: '^ngModel', 
     scope: { 
      ngModel: '=' 
     }, 
     controller: ['$scope', function ($scope) { 
       $scope.setup = function (element) { 
        element.attr('mentio', 'mentio'); 
        element.attr('mentio-typed-term', 'typedTerm'); 
        element.attr('mentio-require-leading-space', 'true'); 
        element.attr('mentio-id', "'content-editor-{{$id}}'"); 
       }; 

回答

0

我解決這個問題的方法是通過編寫一個函數返回mentio換價值。

<mentio-menu mentio-for="getContentId()" 
    mentio-trigger-char="'@'" 
    mentio-items="people" 
    mentio-template-url="/iterator.tpl" 
    mentio-search="searchPeople(term)" 
    mentio-select="getPeopleText(item)"> 

然後,在你的指令,創建這樣一個功能:

$scope.getContentId = function() { 
       return 'content-editor-' + $scope.id; 
      }; 
相關問題