Data Properties are defined by creating a data structure on your component and assigning each property a default value.
<!--- ./wires/SomeComponent.cfm ---><cfscript> data = { "propertyName": "defaultValue" };</cfscript>
Property names must be surrounded by single or double quotes.
JavaScript is a case-sensitive language and CFML isn't. To preserve the casing of your property names, you must surround them with quotes.
// Bad
data = {
propertyName: "defaultValue"
};
// Good
data = {
"propertyName": "defaultValue"
};
Data Properties are parsed by JavaScript and therefore can only store values that are JavaScript friendly: strings, numeric, arrays, structs, or booleans.
Data Properties are visible to JavaScript. You SHOULD NOT store sensitive data in them.
Initial Values
Data properties should be assigned a default value, even if it's just an empty string.
<cfscript> data = { "success": false, "message: "Hello World" };</cfscript>
Using Data Properties
You can access Data Properties from within your component Actions like so.
<cfscript> // Data properties data = { "task": "" }; // Action function addTask(){ taskService.create( data.task ); data.task = ""; }</cfscript>
You can also reference Data Properties within your component template using #propertyName#.