Skip to content
This repository was archived by the owner on Apr 30, 2018. It is now read-only.

Commit e7192f9

Browse files
committed
Update README.md
Added examples
1 parent bd5a290 commit e7192f9

File tree

1 file changed

+67
-19
lines changed

1 file changed

+67
-19
lines changed

README.md

Lines changed: 67 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,78 @@
11
## Formly
22
Formly for Angular is an AngularJS module which has directives to help customize and render JSON based forms. The directive originated from a need to allow our users to create surveys and distribute them easily. Currently we've can render the form data from JSON and assign a model to form so we can receive the submitted data.
33

4-
<formly-form result="formData" fields="formFields" options="formOptions" ng-submit="onSubmit()">
5-
</formly-form>
4+
<formly-form result="formData" fields="formFields" options="formOptions" ng-submit="onSubmit()">
5+
</formly-form>
66

77
### Demo : http://Nimbly.github.io/angular-formly/
88

99
## Dependencies
10-
- required:
11-
[TODO]
12-
- optional
13-
[TODO]
10+
- Required to use Formly:
11+
- Angular
12+
- Twitter Bootstrap
13+
14+
- Dev dependencies to build Formly
15+
- npm
16+
1417

1518
See `bower.json` and `index.html` in the `master` branch for a full list / more details
1619

1720
## Install in your project
18-
1. download the files
19-
1. Bower
20-
1. run `bower install angular-formly`
21-
2. include the files in your app
22-
1. `bower_components/angular-formly/dist/formly.min.js`
23-
3. include the module in angular (i.e. in `app.js`) - `formly`
24-
`var app = angular.module('app', ['ng', 'ui.router', 'formly']);`
21+
1. Install with Bower
22+
`$ bower install angular-formly`
23+
24+
2. Include the files in your index.html
25+
`<script src="bower_components/angular-formly/dist/formly.min.js"></script>`
26+
27+
3. Add 'formly' as a required module to your angular app, usually in `app.js`:
28+
`var app = angular.module('app', ['ng', 'ui.router', 'formly']);`
2529

2630
## Documentation
27-
[TODO]
31+
32+
```html
33+
<formly-form result="formData" fields="formFields" options="formOptions" ng-submit="onSubmit()">
34+
</formly-form>
35+
```
36+
37+
For options specific to input types see their directive html in `src/directives`
38+
```javascript
39+
var formFields = [
40+
{
41+
//the key to be used in the result values {... "username": "johndoe" ... }
42+
key: 'username',
43+
44+
//default value
45+
default: 'uberuser'
46+
type: 'text',
47+
label: 'Username',
48+
placeholder: 'johndoe',
49+
required: true,
50+
disabled: false, //default: false
51+
},
52+
{
53+
key: 'password'
54+
type: 'password',
55+
label: 'Password',
56+
required: true,
57+
disabled: false, //default: false
58+
}
59+
60+
];
61+
62+
var formOptions = {
63+
64+
//Set the id of the form
65+
uniqueFormId: 'myFormId',
66+
67+
//Hide the submit button that is added automaticaly
68+
//default: false
69+
hideSubmit: false,
70+
71+
//Set the text on the default submit button
72+
//default: Submit
73+
submitCopy: 'Login'
74+
};
75+
```
2876

2977
## Roadmap
3078

@@ -33,12 +81,12 @@ See `bower.json` and `index.html` in the `master` branch for a full list / more
3381
## Development
3482

3583
1. `git checkout master`
36-
1. run `npm install && bower install`
37-
2. test your code using `grunt dev` which hosts the app at `http://localhost:4000`
38-
3. commit your changes
84+
1. run `npm install && bower install`
85+
2. test your code using `grunt dev` which hosts the app at `http://localhost:4000`
86+
3. commit your changes
3987
3. update README, CHANGELOG, bower.json, and do any other final polishing to prepare for publishing
40-
1. git commit changes
88+
1. git commit changes
4189

4290
## Grunt targets
43-
* `grunt dev`: Creates a server for testing at `http://localhost:400`
91+
* `grunt dev`: Creates a server for testing at `http://0.0.0.0:4000`
4492
* `grunt publish`: Copies the src folder and bower_components to gh-pages

0 commit comments

Comments
 (0)