28
28
npm install fittable-angular
29
29
```
30
30
31
+ ## Angular component example
32
+
31
33
### tsconfig.json (for non-ECMAScript module dependants)
32
34
33
35
``` json
@@ -52,57 +54,63 @@ npm install fittable-angular
52
54
}
53
55
```
54
56
55
- ## API Overview
57
+ ### app.module.ts
56
58
57
- ### HTML
59
+ ``` typescript
60
+ import { NgModule } from ' @angular/core' ;
61
+ import { BrowserModule } from ' @angular/platform-browser' ;
58
62
59
- ``` html
60
- <div style =" width :100% ;height :300px ;" >
61
- <!-- Angular component -->
62
- <fittable [designer] =" fit" ></fittable >
63
- </div >
63
+ import { registerModelConfig } from ' fittable-core/model' ;
64
+ import { registerOperationConfig } from ' fittable-core/operations' ;
65
+ import { registerViewModelConfig } from ' fittable-core/view-model' ;
66
+ import { FIT_MODEL_CONFIG } from ' fittable-model' ;
67
+ import { FIT_OPERATION_CONFIG } from ' fittable-model-operations' ;
68
+ import { FIT_VIEW_MODEL_CONFIG } from ' fittable-view-model' ;
69
+ import { NgxFittableModule } from ' fittable-angular' ;
70
+
71
+ import { AppComponent } from ' ./app.component' ;
72
+
73
+ // Register functionalities
74
+ registerModelConfig (FIT_MODEL_CONFIG );
75
+ registerOperationConfig (FIT_OPERATION_CONFIG );
76
+ registerViewModelConfig (FIT_VIEW_MODEL_CONFIG );
77
+
78
+ @NgModule ({
79
+ declarations: [AppComponent ],
80
+ imports: [BrowserModule , NgxFittableModule ],
81
+ providers: [],
82
+ bootstrap: [AppComponent ],
83
+ })
84
+ export class AppModule {}
64
85
```
65
86
66
- ### TypeScript
87
+ ### app.component.ts
67
88
68
89
``` typescript
69
90
import { Component , OnInit } from ' @angular/core' ;
70
91
71
- // TypeScript modules
72
92
import {
73
93
CellRange ,
74
94
createStyle ,
75
95
createTable ,
76
- registerModelConfig ,
77
96
Table ,
78
97
} from ' fittable-core/model' ;
79
- import { registerOperationConfig } from ' fittable-core/operations' ;
80
98
import {
81
99
createFittableDesigner ,
82
100
FittableDesigner ,
83
- registerViewModelConfig ,
84
101
} from ' fittable-core/view-model' ;
85
- import { FitStyle , FitTable , FIT_MODEL_CONFIG } from ' fittable-model' ;
86
- import {
87
- FitOperationArgs ,
88
- FIT_OPERATION_CONFIG ,
89
- } from ' fittable-model-operations' ;
90
- import { FIT_VIEW_MODEL_CONFIG } from ' fittable-view-model' ;
102
+ import { FitStyle , FitTable } from ' fittable-model' ;
103
+ import { FitOperationArgs } from ' fittable-model-operations' ;
91
104
92
105
@Component ({
93
- selector: ' sample ' ,
94
- templateUrl: ' ./sample .component.html' ,
95
- styleUrls: [' .sample/common .css' ],
106
+ selector: ' app-root ' ,
107
+ templateUrl: ' ./app .component.html' ,
108
+ styleUrls: [' ./app.component .css' ],
96
109
})
97
- export class SampleComponent implements OnInit {
110
+ export class AppComponent implements OnInit {
98
111
public fit! : FittableDesigner ;
99
112
100
113
public ngOnInit(): void {
101
- // Register functionalities
102
- registerModelConfig (FIT_MODEL_CONFIG );
103
- registerOperationConfig (FIT_OPERATION_CONFIG );
104
- registerViewModelConfig (FIT_VIEW_MODEL_CONFIG );
105
-
106
114
// Build table model
107
115
const table: Table = createTable <FitTable >()
108
116
.setNumberOfRows (100 )
@@ -134,3 +142,38 @@ export class SampleComponent implements OnInit {
134
142
}
135
143
}
136
144
```
145
+
146
+ ### app.component.html
147
+
148
+ ``` html
149
+ <div class =" fittable" >
150
+ <!-- Angular component -->
151
+ <fittable [designer] =" fit" ></fittable >
152
+ </div >
153
+ ```
154
+
155
+ ### app.component.css
156
+
157
+ ``` css
158
+ .fittable {
159
+ position : relative ;
160
+ width : 100% ;
161
+ height : 100% ;
162
+ }
163
+ ```
164
+
165
+ ### styles.css
166
+
167
+ ``` css
168
+ html ,
169
+ body {
170
+ position : relative ;
171
+ width : 100% ;
172
+ height : 100% ;
173
+ margin : 0px ;
174
+ padding : 0px ;
175
+ overflow : hidden ;
176
+ }
177
+ ```
178
+
179
+ <p >The demo component can be found <a href =" https://github.com/ionutkosteea/fittable/tree/main/angular-app/ngx-fittable-test " >here</a >.<p >
0 commit comments