What is the synthetic angular property?

Recently, developing an animated component, I came across a term synthetic property.

<bmx-panel [@sidebarState]="state">

  <i bmxPanelHeader (click)="toggle($event)"
     class="fa fa-angle-double-right fa-lg"></i>
  ...    
</bmx-panel>

In my case, a synthetic property [@sidebarState]="state"triggers an extension / collapse animation of my component when the property is statechanged by a function toggle.

The first parameter of the method triggeris the name of the corresponding synthetic property @sidebarState.

@Component({
  selector: 'app-sidebar',
  templateUrl: './sidebar.component.html',
  styleUrls: ['./sidebar.component.scss'],
  animations: [
    trigger('sidebarState', [
      state('expanded', style( { width: '240px' } )),
      state('collapsed', style({ width: '40px' })),
      transition('expanded => collapsed', animate('350ms ease-in')),
      transition('collapsed => expanded', animate('350ms ease-out'))
    ])
  ]
})
export class SidebarComponent  {  
  public state = 'expanded';

  constructor() {}

  toggle(event: any) {    
    this.state = this.state === "expanded" ? "collapsed" : "expanded";  
  }
}

Google searches do not contain much information about synthetic properties. Nothing is mentioned in the angular documentation. Does anyone have a deeper understanding of this concept?

+4
source share
1 answer

, Angular, . .

0

Source: https://habr.com/ru/post/1690097/


All Articles