Home > database >  what's the meaning of '=?<name>' in angularJS directive isolate scope declarati
what's the meaning of '=?<name>' in angularJS directive isolate scope declarati

Time:06-14

Does the question mark after equals have special meaning? Example: scope: {enumMapping: '=?enumMapping'} I understand '=?' but this is first time I see it. Anyone explain for me.

CodePudding user response:

The question mark (?) means that the value is not required, so 'enumMapping' can be undefined.

The notation 'enumMapping: '=?enumMapping' can be abbreviated to 'enumMapping: '=?' since the name of the attribute is equal to the internal property.

Instead, when the html attribute used it's different from the internal property, it is required to specify it, eg. 'enumMapping: '=?myExternalAttr'

<my-directive my-external-attr=someValue></my-directive>
  • Related