Skip to content

Commit 82de1cc

Browse files
committed
tweak readme
1 parent 3094033 commit 82de1cc

File tree

1 file changed

+66
-54
lines changed

1 file changed

+66
-54
lines changed

README.md

Lines changed: 66 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -18,58 +18,6 @@ This command automatically installs the necessary files, as well as stores nativ
1818

1919
## Usage
2020
You need to add `xmlns:gv="nativescript-grid-view"` to your page tag, and then simply use `<gv:GridView/>` in order to add the widget to your page. Use `<gv:Gridview.itemTemplate/>` to specify the template for each cell:
21-
```XML
22-
<Page xmlns="http://schemas.nativescript.org/tns.xsd"
23-
xmlns:gv="nativescript-grid-view">
24-
<GridLayout>
25-
<gv:GridView>
26-
<gv:GridView.itemTemplate>
27-
<GridLayout>
28-
<Label text="Text"/>
29-
</GridLayout>
30-
</gv:GridView.itemTemplate>
31-
</gv:GridView>
32-
</GridLayout>
33-
</Page>
34-
```
35-
36-
### In nativescript-angular:
37-
38-
Template:
39-
```HTML
40-
<GridView [items]="items" colWidth="33%" rowHeight="50%" padding="5">
41-
<ng-template let-item="item">
42-
<StackLayout [nsRouterLink]="['/item', item.id]" borderColor="blue" borderWidth="2" borderRadius="5" verticalAlignment="stretch" class="list-group-item">
43-
<Label verticalAlignment="center" [text]="item.name" class="list-group-item-text"></Label>
44-
</StackLayout>
45-
</ng-template>
46-
</GridView>
47-
```
48-
49-
In your app-module:
50-
```typescript
51-
import { GridViewModule } from 'nativescript-grid-view/angular';
52-
53-
@NgModule({
54-
bootstrap: [
55-
...
56-
],
57-
imports: [
58-
...
59-
GridViewModule,
60-
],
61-
declarations: [
62-
...
63-
],
64-
providers: [
65-
...
66-
],
67-
schemas: [
68-
NO_ERRORS_SCHEMA
69-
]
70-
})
71-
export class AppModule { }
72-
```
7321

7422
## API
7523

@@ -117,7 +65,7 @@ Gets or sets the width for every column in the GridView.
11765
Forces the GridView to reload all its items.
11866

11967
## Example
120-
```XML
68+
```xml
12169
<!-- test-page.xml -->
12270
<Page xmlns="http://schemas.nativescript.org/tns.xsd" xmlns:gv="nativescript-grid-view" loaded="pageLoaded">
12371
<GridLayout>
@@ -132,7 +80,7 @@ Forces the GridView to reload all its items.
13280
</Page>
13381
```
13482

135-
```TypeScript
83+
```ts
13684
// test-page.ts
13785
import { EventData, Observable } from "data/observable";
13886
import { ObservableArray } from "data/observable-array";
@@ -168,6 +116,66 @@ export function gridViewLoadMoreItems(args: EventData) {
168116
}
169117
```
170118

119+
## Angular:
120+
121+
Import `GridViewModule` in your `NgModule`:
122+
123+
```typescript
124+
import { GridViewModule } from 'nativescript-grid-view/angular';
125+
126+
@NgModule({
127+
//......
128+
imports: [
129+
//......
130+
GridViewModule,
131+
//......
132+
],
133+
//......
134+
})
135+
```
136+
137+
#### Example Usage
138+
```ts
139+
// app.module.ts
140+
import { GridViewModule } from "nativescript-grid-view/angular";
141+
142+
@NgModule({
143+
bootstrap: [
144+
AppComponent
145+
],
146+
imports: [
147+
NativeScriptModule,
148+
AppRoutingModule,
149+
GridViewModule,
150+
],
151+
declarations: [
152+
AppComponent,
153+
ItemsComponent,
154+
ItemDetailComponent
155+
],
156+
providers: [
157+
ItemService
158+
],
159+
schemas: [
160+
NO_ERRORS_SCHEMA
161+
]
162+
})
163+
export class AppModule { }
164+
```
165+
166+
```html
167+
<!-- my.component.html -->
168+
<GridLayout class="page">
169+
<GridView [items]="items" colWidth="30%" rowHeight="100">
170+
<ng-template let-item="item" let-odd="odd">
171+
<StackLayout margin="10" [nsRouterLink]="['/item', item.id]" borderColor="blue" borderWidth="2" borderRadius="5" verticalAlignment="stretch" class="list-group-item" [class.odd]="odd">
172+
<Label verticalAlignment="center" [text]="item.name" class="list-group-item-text" textWrap="true"></Label>
173+
</StackLayout>
174+
</ng-template>
175+
</GridView>
176+
</GridLayout>
177+
```
178+
171179
## Working with Webpack+Uglify
172180
In case you are uing webpack and also are minifying/uglifying your code, there are some specific names that should be excluded from the uglification for the widget to work properly. The GridView widget exports those and you need to add them to the mangle exclude option of the uglifyjs plugin in the `webpack.common.js` file:
173181
```js
@@ -192,3 +200,7 @@ module.exports = function (platform, destinationApp) {
192200
//......
193201
}
194202
```
203+
204+
## Donate
205+
`bitcoin:14fjysmpwLvSsAskvLASw6ek5XfhTzskHC`
206+
![Donate](https://www.tangrainc.com/qr.png)

0 commit comments

Comments
 (0)