user3461101
user3461101

Reputation: 45

Directives enclosing scope Angular

Having trouble binding my directive to a model in the controller enclosing it. The value for ng-model is not being put in the directive. The value of the model remains the variable name "val" once rendered.

template:
  '<div ng-model="value" id="{{textareaId}}" style="resize:vertical;height:{{textareaHeight || \'80px\'}}; overflow:auto" contentEditable="true" class="{{textareaClass}} wysiwyg-textarea" rows="{{textareaRows}}" name="{{textareaName}}" required="{{textareaRequired}}" placeholder="{{textareaPlaceholder}}"></div>' +
  '</div>',
restrict: 'E',
scope:{
  value: '=ngModel',
  textareaHeight: '@textareaHeight',
  textareaName: '@textareaName',
  textareaPlaceholder: '@textareaPlaceholder',
  textareaClass: '@textareaClass',
  textareaRequired: '@textareaRequired',
  textareaId: '@textareaId',
},

How do I bind in this circumstance.

Upvotes: 0

Views: 104

Answers (1)

farolfo
farolfo

Reputation: 388

What about ngModelController ? You have to specify the

require: 'ngModel'

in the directive and then use the 4th parameter in the link function for example. You have more info here, I hope it helps ;) http://www.chroder.com/2014/02/01/using-ngmodelcontroller-with-custom-directives/

Upvotes: 1

Related Questions