JavaScript Alternative or better approach for *NgIf

Hi I have several *NgIf conditions in my template. Based on the NgIf I display/render my components(different type of form) in the template. Example in one of my function (below)

private _onClick(cell:any){
        this._enableView = false;
        this._enableCreate = true;
        this._enableDelete = false;
        this._enableEdit = false;
    }

Which is to enable my create form in the template and hide other forms if its there. But doing so feel like bit wrong or redundant to me. Is there any better approach or suggestion instead of this approach?

Answer:1

If it is possible to have a single state as suggested by Leguest I would recommend ngswitch used like this:

// Syntax for ngSwitch
<div [ngSwitch]="state">
    <div *ngSwitchCase="'create'"> ... </div>
    <div *ngSwitchCase="'view'">  ... </div>
    <div *ngSwitchCase="'edit'"> ... </div>
    <div *ngSwitchCase="'delete'"> ... </div>
    <div *ngSwitchDefault> ... </div>
</div>

Otherwise if you are using Angular 4.x you can take advantage of ngIf else:

// Syntax for ngIf/Else
<div *ngIf=”condition; else elseBlock”>Truthy condition</div>
<template #elseBlock>Falsy condition</template>
Answer:2

React Charts 2 https://github.com/gor181/react-chartjs-2 is referencing below Chart JS http://www.chartjs.org/docs/#getting-started The docs in react-chartjs-2 references chart.js docs and they're ...

React Charts 2 https://github.com/gor181/react-chartjs-2 is referencing below Chart JS http://www.chartjs.org/docs/#getting-started The docs in react-chartjs-2 references chart.js docs and they're ...

  1. react chartjs options

I have a datetimepicker, I'm needing this to pass the date inside the text to the model. I would place this in a fiddle but i don't know how as it has the bootstrap timepicker located here http://...

I have a datetimepicker, I'm needing this to pass the date inside the text to the model. I would place this in a fiddle but i don't know how as it has the bootstrap timepicker located here http://...

Let's say I have a div like below and my goal is to set it's css class to some computed string of classes based on the name of a vue data model property passed to the getClassText method: <div :...

Let's say I have a div like below and my goal is to set it's css class to some computed string of classes based on the name of a vue data model property passed to the getClassText method: <div :...

  1. data value model
  2. key value data model
  3. key value data model example
  4. nursing value data model
  5. entity value data model
  6. attribute value data model
  7. cube value data model
  8. value proposition data model
  9. multi-value data model
  10. data value chain model
  11. entity attribute value data model
  12. data value creation model
  13. nosql key value data model
  14. value of enterprise data model
  15. data value business model
  16. value of conceptual data model
  17. customer value model data
  18. key value pair data model
  19. key value store data model
  20. data value chain reference model

I'm using Mapbox GL JS API to manipulate a Mapbox map. Right before I upload my result (which is a canvas.toDataURL) to the server through HTTP I need to resize my map (bigger resolution) and then use ...

I'm using Mapbox GL JS API to manipulate a Mapbox map. Right before I upload my result (which is a canvas.toDataURL) to the server through HTTP I need to resize my map (bigger resolution) and then use ...

  1. mapbox event on click
  2. mapbox on event