Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional flex in Angular material

Given the bootstrap layout definition

ng-class="{'col-sm-6':vm.data.mode === 'ADD', 'col-sm-3': vm.data.mode === 'EDIT'}"

What's the angular material equivalent? (To set flex="50" if vm.data.mode === 'ADD' and set flex="25" if vm.data.mode === 'EDIT')

like image 570
user3024814 Avatar asked Jun 22 '16 07:06

user3024814


People also ask

What is flex in angular material?

Angular Flex-Layout is a stand-alone library developed by the Angular team for designing sophisticated layouts. When creating an HTML page in Angular, using Angular Flex-Layout allows us to easily create FlexBox-based page layouts with a set of directives available for use in your templates.

Does angular material use Flexbox?

Angular Material's Layout features provide sugar to enable developers to more easily create modern, responsive layouts on top of CSS3 flexbox. The layout API consists of a set of Angular directives that can be applied to any of your application's HTML content.

How do I install Flex-Layout in angular material?

From your project folder, run the following command to install Flex Layout: npm install @angular/flex-layout @10.0. 0-beta.

What is fxLayout row wrap?

fxLayout defines the flow of children elements along the main-axis or cross-axis, inside the flex container. Depending upon our layout we can pass four different values to the fxLayout attribute row,column, row-reverse and column-reverse. In addition to the fxLayout accepts other parameters like wrap and inline.


1 Answers

You can try below.

<div layout="row" layout-wrap>
  <div flex-gt-sm="{{vm.data.mode === 'ADD' ? 50: 25}}"></div>
  <div flex-gt-sm="{{vm.data.mode === 'ADD' ? 50: 25}}"></div>
  <div flex-gt-sm="{{vm.data.mode === 'ADD' ? 50: 25}}"></div>
</div>
like image 52
Pankaj Parkar Avatar answered Sep 20 '22 14:09

Pankaj Parkar