Big questions are some info:
1) There are two general ways (as I understand it) that a web component can be enabled on a page. This is <compose>
and write a custom element. My question, coming from Angular, is of great importance for areas (i.e. that which is in scope at a specific point of the DOM). I am interested in what is in the "volume" (i.e., Available to bind the expression) in the composition and user elements. I mean, is the parent view model available in the child template? If so, do the child view-model properties hide / shadow properties of the parent view model?
Consider the following markup:
app.html
<template> <h1>${message}</h1> <date-picker value.bind="startDate"></date-picker> <compose view="footer.html"></compose> <template>
<compose>
retains access to the external area. When the template contained in footer.html
is data bound, it will have access to what app.html
bound app.html
, for example, it can access the message
property.
The custom item template cannot access the outside area. Custom elements are designed for encapsulation and portability. For this reason, they are not allowed access to the external area, which prevents developers from creating custom elements that are expected to be used in specific binding contexts. The main way to get data to / from a user element is through @bindable
properties (similar to dependency properties in XAML).
2) In Angular 2, there are recommendations on how data is transmitted and exited from components. We should not change the nonprimitives bound to the component (because this forces Angular 2 to change the detection to always go into this component branch to check all the properties).
Are there any recommendations / information for transferring data to and from components in Aurelia? I mean from the reading I did, it sounds like I would just use value.bind
to bind to all @bindable
properties. It is right?
right
Are these two-way links by default or do I need to explicitly declare value.two-way
? Is there something wrong with changing the properties of a two-way related object?
Aurelia automatically selects the correct default snap mode for attributes of inline elements, such as inputs or selections. You need to specify default values ββfor custom items if you want something other than one-way
. Here's how to do it:
import {bindingMode} from 'aurelia-framework';