无法将配置传递给ngModel

时间:2017-07-12 19:45:15

标签: html angularjs angularjs-directive

指令

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>

我得到结果ng-model =“ngModel”而不是ng-model =“title”。我尝试将我的模板ng-model =“ngModel”更改为ng-model =“{{ngModel}}”。但它没有用。不确定为什么。

1 个答案:

答案 0 :(得分:0)

尝试将指令的范围更改为

[[A[i], B[i]] for i in range(len(A))]

,模板应为

scope: {
   options: '=',
   bindModel:'=ngModel'
},
相关问题