1.0.23 • Published 7 years ago

a2-widgets v1.0.23

Weekly downloads
10
License
ISC
Repository
github
Last release
7 years ago

Angular 2; flex widgets

Installation

You can add a2-widgets to your project using npm;

npm install a2-widgets --save

Configuration

  1. Create a json file that defines your widgets. Example widget definitions json file;

                {
                    "widgets": [
                        {
                                "title": "Widget HTML",
                                "html": "<b>This is some static HTML...</b>"
                        }, 
                        {
                                "title": "Widget Component",
                                "component": "app-hello",
                                "style": {
                                        "height": "400px"
                                }
                        }, 
                        {
                                "title": "Widget iFrame",
                                "url": "https://weather.com/",
                                "classes": ["unpadded"]
                        }
                   ]
                }

    Note: The contents of the json file are ignored except for the widgets array which is mapped to this interface;

    export interface WidgetInterface {
        id?:string;         // unique id automatically assigned
        title?: string;     // title of widget
        html?: string;      // html to be rendered
        url?: string;       // url to be iframed
        component?: string; // component selector
        classes?: string[]; // array of class names
        style?: any;        // style object, e.g. {"prop1": "value", "prop2": "value", ... "propN": "value"}
    };
  1. Add the WidgetsModule to your app module.

    In this example, one widget will render the HelloComponent, so the HelloComponent is added to the components section of the WidgetsModule's options and to the entryComponents array.

        Import { WidgetsModule } "a2-widgets/widgets.module";
    
        @NgModule({
        imports: [
            ...
            WidgetsModule.setOptions({ 
                widgets_url: "./app/resources/data/custom.json",
                components: {
                    'app-hello': HelloComponent
                }
            }),
            ...
            ],
            entryComponents: [
              HelloComponent
            ],
            ...
            bootstrap: [AppComponent]
    })
  2. If you are using routes, add the widgets.component to your route table. Otherwise add the widgets to DOM;

        <app-widgets></app-widgets>

Example

1.0.23

7 years ago

1.0.22

7 years ago

1.0.21

7 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

7 years ago

1.0.13

7 years ago

1.0.12

7 years ago

1.0.11

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago