JSTemplateComponent

JSTemplateComponent

new JSTemplateComponent(tagName, options, callback)

Source:
Example
Application.require('js-template-component')
     .then(function (
         // @type {JSTemplateComponent}
         JSTemplateComponentConstructor
     ) {
         new JSTemplateComponentConstructor(
             'my-custom-tagname',
             {
                 context: {
                     numberOfClicks: 0
                 },
                 templateCode: `
                     <div>
                         {{ this.numberOfClicks }}
                         <button (click)="this.increaseClicksNumber()">
                         </button>
                     </div>
                 `,
                 sharedPrototypeMethods: {
                     increaseClicksNumber: function () {
                         this.numberOfClicks += 1;
                     }
                 },
                 sharedReferences: {},
                 cssStyles: [
                     '/some/styles/style.css'
                 ]
             },
             function (err) {
                 if (err) console.error(err);
             }
         );
     }).catch(console.error);
Parameters:
Name Type Description
tagName string
options JSTemplateComponent.options
callback JSTemplateComponent.constructorCallback

Interfaces

contextInstance
contextWithInstance
contextWithoutInstance

Type Definitions

Builder(tagName, options, callback) → {JSTemplateComponent}

Source:
Parameters:
Name Type Description
tagName string
options JSTemplateComponent.options
callback JSTemplateComponent.constructorCallback
Returns:
Type
JSTemplateComponent

constructorCallback(err)

Source:
Parameters:
Name Type Description
err Error

contextLifeCycle

Source:
Properties:
Name Type Attributes Description
init JSTemplateComponent.lifeCycleCallback <optional>

callbacks on init

getReferences JSTemplateComponent.lifeCycleCallbackGetReferences <optional>

returns

contentChange JSTemplateComponent.lifeCycleCallback <optional>

callback on content change

attrChange JSTemplateComponent.lifeCycleCallback <optional>

context object default is Node

remove JSTemplateComponent.lifeCycleCallback <optional>

context object default is Node

Type:
  • object

lifeCycleCallback(context, references, methods)

Source:
Parameters:
Name Type Description
context JSTemplateComponent.contextWithInstance
references Object.<string, any>
methods Object.<string, any>

lifeCycleCallbackGetReferences(context, sharedReferences, sharedPrototypeMethods) → {object}

Source:
Parameters:
Name Type Description
context JSTemplateComponent.contextWithInstance
sharedReferences object
sharedPrototypeMethods object
Returns:
Type
object

options

Source:
Properties:
Name Type Attributes Default Description
context function <optional>

context object default is Node

__lifeCycle JSTemplateComponent.contextLifeCycle <optional>

context object default is Node

templateCode string <optional>

template Code

templateUrl string <optional>

template URL

cssStyles Array.<string> <optional>

list of URLs that point to styles

sharedReferences object <optional>

references that will be same for all created components

sharedPrototypeMethods object <optional>

methods that will be on all components under method "methods"

__flag_RejectOnStylesError boolean <optional>
false
Type:
  • object