2017-07-12 3 views
0

RichtlinieKonfiguration kann nicht zu ngModel passieren

return { 
    restrict: 'E', 
    replace: true, 
    transclude: true, 
    require: ['^?angular-redactor', '^?ngModel'], 
    scope: { 
     options: '=' 
    }, 
     template: `<div ng-if="options.type=='redactor'"> 
      <textarea 
       id="{{options.id}}" 
       ng-model="ngModel" 
       ng-disabled="!hasPermission('editPageTitle')" 
       height="{{options.height}}" 
       style="{{options.style}}" 
       redactor="{{options.config}}"> 
      </textarea> 
      </div>` 
     } 

HTML

<txt ng-model="title" 
    options="{ 
     type: 'redactor', 
     id: 'title-input', 
     height: '26px', 
     style: 'resize:none; max-height: 32px' , 
     config: { 
      minHeight: 37 
     } 
    }"> 
</txt> 

ich das Ergebnis ng-Modell = "ngModel" get statt ng-Modell = "title". Ich habe versucht, meine Vorlage ng-model = "ngModel" in ng-model = "{{ngModel}}" zu ändern. Aber es hat nicht funktioniert. Nicht sicher warum.

Antwort

0

Versuchen Sie, den Anwendungsbereich der Richtlinie zu

scope: { 
    options: '=', 
    bindModel:'=ngModel' 
}, 

und die Vorlage sollte

template: `<div ng-if="options.type=='redactor'"> 
     <textarea 
      id="{{options.id}}" 
      ng-model="bindModel" 
      ng-disabled="!hasPermission('editPageTitle')" 
      height="{{options.height}}" 
      style="{{options.style}}" 
      redactor="{{options.config}}"> 
     </textarea> 
     </div>` 
    } 
+0

Haben Sie nicht traurig arbeiten zu ändern. Die Ausgabe war nur 'ng-model =" bindModel "' anstelle des gewünschten 'ng-model =" title "' –

Verwandte Themen