1
- # Include [ Flex Layout] ( https://github.com/angular/flex-layout ) in your CLI application
1
+ ## Include [ Flex Layout] ( https://github.com/angular/flex-layout ) in your CLI application
2
2
3
- Include Angular Flex layout as detailed above.
3
+ <a href =" https://tburleson-layouts-demos.firebaseapp.com/#/docs " target =" _blank " >
4
+ <img src =" https://user-images.githubusercontent.com/210413/28999595-65e9be78-7a11-11e7-9403-69ecae10fcb4.png " ></img >
5
+ </a >
4
6
5
- Install the ` @angular/flex-layout ` library and add the dependency to package.json...
7
+ > Above is snapshot of a [ Online Demos] ( https://tburleson-layouts-demos.firebaseapp.com/#/docs ) using @angular/flex-layout
8
+
9
+
10
+ <br />
11
+
12
+ ### Include ` @angular/flex-layout ` as detailed below:
13
+
14
+ Install the library and add the dependency to package.json...
6
15
``` bash
7
16
npm install --save @angular/flex-layout
8
17
```
9
18
19
+ Or install the nightly build using:
20
+
21
+ ``` bash
22
+ npm i --save @angular/flex-layout-builds
23
+ ```
24
+
10
25
Import the Angular Flex-Layout NgModule into your app module...
11
26
``` javascript
12
27
// in src/app/app.module.ts
@@ -25,53 +40,45 @@ import { FlexLayoutModule } from '@angular/flex-layout';
25
40
26
41
Run ` ng serve ` to run your application in develop mode, and navigate to ` http://localhost:4200 `
27
42
28
- Add the following to ` src/app/app.component.css ` ...
29
- ``` css
30
- .header {
31
- background-color : lightyellow ;
32
- }
43
+ <br />
33
44
34
- .left {
35
- background-color : lightblue ;
36
- }
45
+ ### Sample App
37
46
38
- .right {
39
- background-color : pink ;
40
- }
47
+ Add the following to ` src/app/app.component.css ` ...
48
+ ``` css
49
+ [fxLayout = " column" ] { border : 1px solid ;padding :4px ; margin-top :50px ; },
50
+ [fxFlex ]{ padding :5px ;},
51
+ h3 { padding-top :20px ; },
52
+ .header { background-color : lightyellow ; },
53
+ .left { background-color : lightblue ; },
54
+ .right { background-color : pink ; }
41
55
```
42
56
43
57
To verify flex-layout has been set up correctly, change ` src/app/app.component.html ` to the following...
44
58
``` html
45
- <div fxLayout =" column" >
46
-
47
- <div class =" header" fxLayout =" row" fxLayoutAlign =" space-between center" >
48
-
49
- <h1 >
50
- {{title}}
51
- </h1 >
52
-
53
- </div >
54
-
55
- <div fxLayout =" row" >
56
-
57
- <div class =" left" fxFlex =" 20" >
58
- LEFT: 20% wide
59
- </div >
60
-
61
- <div class =" right" fxFlex >
62
- RIGHT: 80% wide
63
- </div >
64
-
65
- </div >
66
- </div >
67
- ```
59
+ <div fxLayout =" column" >
60
+ <div class =" header" fxLayout =" row" fxLayoutAlign =" space-between center" >
61
+ <h3 >
62
+ {{title}}
63
+ </h3 >
64
+ </div >
65
+ <div fxLayout =" row" >
66
+ <div class =" left" fxFlex =" 20" > LEFT: 20% wide </div >
67
+ <div class =" right" fxFlex > RIGHT: 80% wide </div >
68
+ </div >
69
+ </div >
70
+ ```
68
71
69
72
After saving this file, return to the browser to see the very ugly but demonstrative flex-layout.
70
73
74
+ ![ screen shot 2017-08-05 at 7 20 05 pm] ( https://user-images.githubusercontent.com/210413/28999629-35c566a0-7a13-11e7-8d36-1d1a2244443c.png )
75
+
71
76
Among what you should see are - a light yellow header that is the entire width of the window, sitting directly atop 2 columns. Of those 2 columns, the left column should be light blue, and 20% wide, while the right column is pink, 80% to start, and will flex with window (re)size.
72
77
78
+ <br />
79
+
73
80
### More Info
74
81
75
- - [ Installation] ( https://github.com/angular/flex-layout#installation )
76
- - [ API Overview] ( https://github.com/angular/flex-layout/wiki/API-Overview )
82
+ - [ Installation] ( https://github.com/angular/flex-layout/wiki/Using-Angular-CLI )
83
+ - [ API Overview] ( https://github.com/angular/flex-layout/wiki/Declarative- API-Overview )
77
84
- [ Demo] ( https://tburleson-layouts-demos.firebaseapp.com/#/docs )
0 commit comments