有人可以解释什么是运营商":?"?

时间:2017-07-28 15:11:42

标签: javascript-objects

有人可以解释什么是运营商吗?

 @observable.ref navigationState: ?NavigationState = null;

1 个答案:

答案 0 :(得分:0)

它是安全的导航操作员",即x?.y。

for refrence go here

或采用此示例

  <md-select placeholder="Select Month" [(ngModel)]="monthSelected" 
  #userSelect>

  <md-option *ngFor="let userSelection of CalanderContent" 
  [value]="userSelection">
  {{ userSelection.month }}
  </md-option>
  </md-select>
  {{userSelect.selected.value.days}} <- Compile time error beacuse we didnt selected
                                          any options at time of initializing.
  {{userSelect.selected?.value?.days}} <- Correct because it waits if its selected 
                                          then , displays the value