Sharath
Sharath

Reputation: 606

What does '=?' mean in the scope of a directive in AngularJS?

I have the following code and in that, codeValue property is set to '=?'. Please note the question mark after the equal to symbol.

What does '=?' do?

app.directive('questionMark', function () {  
   return {  
      restrict: 'E',
      scope: {  
         codeValue: "=?"  
      },  
      template: 'Hello world'  
   };  
}); 

Upvotes: 1

Views: 40

Answers (1)

Bill P
Bill P

Reputation: 3618

All 4 kinds of bindings (@, =, <, and &) can be made optional by adding ? to the expression.

It marks the parameter as optional. Read more: https://docs.angularjs.org/api/ng/service/$compile

Upvotes: 1

Related Questions