new JSTemplateComponent(tagName, options, callback)
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
Type Definitions
Builder(tagName, options, callback) → {JSTemplateComponent}
Parameters:
Name | Type | Description |
---|---|---|
tagName |
string | |
options |
JSTemplateComponent.options | |
callback |
JSTemplateComponent.constructorCallback |
Returns:
- Type
- JSTemplateComponent
constructorCallback(err)
Parameters:
Name | Type | Description |
---|---|---|
err |
Error |
contextLifeCycle
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)
Parameters:
Name | Type | Description |
---|---|---|
context |
JSTemplateComponent.contextWithInstance | |
references |
Object.<string, any> | |
methods |
Object.<string, any> |
lifeCycleCallbackGetReferences(context, sharedReferences, sharedPrototypeMethods) → {object}
Parameters:
Name | Type | Description |
---|---|---|
context |
JSTemplateComponent.contextWithInstance | |
sharedReferences |
object | |
sharedPrototypeMethods |
object |
Returns:
- Type
- object
options
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