MikaAK
MikaAK

Reputation: 2364

Can't use binding for ng-model-options

I'm trying to get ng-model-options to work and set it via a binding. However it doesn't seem to work when it's set in the controller.

EG:

This works but I don't want to pass it a string

input.current-page(type='text' ng-model='pageNumber.value' ng-model-options='{getterSetter: true}')

My attempt:

This returns Cannot read property 'updateOn' of undefined

link: function(scope) {
  scope.modelOpts = { getterSetter: true }
})

// view
input.current-page(type='text' ng-model='pageNumber.value' ng-model-options='modelOpts')

Upvotes: 0

Views: 1962

Answers (1)

MikaAK
MikaAK

Reputation: 2364

Interestingly in a directive you cannot set ng-model-options within link. When used in the controller its fine.

IE

// This Will Work
controller: function($scope) {
  $scope.modelOpts = {
    getterSetter: true
  }
},


// This Will Not Work
link: function(scope) {
  scope.modelOpts = {
    getterSetter: true
  }
},

Upvotes: 6

Related Questions