angularjs - RESOLVED: Angular IF ELSE show element -


i setting display type of dashboard , came across problem, how make if else in angular.

is there better way this?

<div ng-if="'config.dashboard.rows == 1'" layout="column" flex> <div ng-if="'config.dashboard.rows > 1'" layout="row" flex> 

resolved:

<div ng-switch on="config.dashboard.rows" flex>      <div ng-switch-when="1" layout="column" flex layout-wrap>          <div ng-repeat="wdg in config.widgets" flex='100' ng-include="wdg.template"></div>      </div>       <div ng-switch-default layout="row" flex layout-wrap>          <div ng-repeat="wdg in config.widgets" flex='50' ng-include="wdg.template"></div>      </div>  </div> 

you use ngswitch directive accomplish this.


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -