Data fill meaning: print data to the page, by binding properties, the page into a dynamic template 1, interpolation expression {{Prop}},{{prop | html}} delimiter and automatic configuration
Meaning: {{prop}} is modified for the nodevalue of a text node and therefore does not affect the sibling node, {{prop}} simply means that the place can be replaced, in Avalon, it is only valid in the text node, it cannot replace the name in the attribute node, The name of the attribute node must begin with ms-.
A, {{prop}}
<meta charset="UTF-8">
<title>avalon-prop</title>
<script type="text/javascript" src="../avalon.min.js"></script>
<script>
avalon.ready(function () {
avalon.define({
$id:"test",
word:"Hello avalon"
})
avalon.scan();
})
</script>
<body>
<div ms-controller="test">
{{word}}
</div>
</body>
*The Avalon has not yet finished loading, but the HTML file is already gorgeous, causing the {{Word}} to leak, what should I do with it?
<style>
.ms-controller{
visibility:hidden;
}
</style>
reference style, which can be displayed normally.
* An interpolation expression, which is not an element property. B, {{Porp | html}} to filter the loaded values.
C, modify the interpolation expression delimiter when the {{}} double-angle brackets are occupied, modifications can be made by modifying the Config method. The length of the suggested delimiter greater than 1, do not set the bit operator to <<>>. For example, before Domready, call the following statement:
avalon.config({
interpolate:["[","]"]
})
<meta charset="UTF-8">
<title>avalon-prop</title>
<script type="text/javascript" src="../avalon.min.js"></script>
<script>
avalon.config({
interpolate:["[[","]]"]
})
avalon.ready(function () {
avalon.define({
$id:"test",
word:"Hello avalon"
})
avalon.scan();
})
</script>
<body>
<div ms-controller="test">
[[word]]
</div>
</body>
2. Binding attribute Ms-text,ms-html,ms-value
A, Ms-test
Meaning: Ms-text is a text binding property that empties the inside of a META element and then internally fills it. Ms-text is actually {{prop}}, the inside of the framework is the same processing function, ms-text as a binding property, must be attached to the element node, so it is not so convenient
<meta charset="UTF-8">
<title>avalon-prop</title>
<script type="text/javascript" src="../avalon.min.js"></script>
<script>
avalon.ready(function () {
avalon.define({
$id:"test",
word:"Hello avalon"
})
avalon.scan();
})
</script>
<body>
<div ms-controller="test" ms-text="word"></div>
</body>
B, ms-html
Meaning: ms-html is an HTML binding property that empties the interior of the original element and then fills it internally. Ms-html is actually {{Porp | html}}, inside the framework is the same handler function, ms-html as a binding property, must be attached to the element node, so it is not so convenient.
<meta charset="UTF-8">
<title>avalon-prop</title>
<script type="text/javascript" src="../avalon.min.js"></script>
<script>
avalon.ready(function () {
avalon.define({
$id:"test",
word:"<p>Hello avalon<p>"
})
avalon.define({
$id:"test2",
word:"<p>Hello avalon</p>"
})
avalon.scan();
})
</script>
<body>
<div ms-controller="test" ms-text="word"></div>
<div ms-controller="test2" ms-html="word"></div>
</body>
the difference between the two is: text prints the stored string as if it were text. HTML will output the stored string as an HTML text element. c, binding attribute Ms-value
meaning: With the ms-value instruction, the data can be displayed through the value values of the form element. Ms-value also supports interpolation expressions in order to handle complex displays, but cannot use filters inside.
<meta charset="UTF-8">
<title>avalon-prop2</title>
<script type="text/javascript" src="../avalon.min.js"></script>
<script type="text/javascript">
avalon.ready(function () {
avalon.define({
$id:"text",
text:‘111‘
})
avalon.scan();
})
</script>
<body>
<div ms-controller="text">
<input type="text" ms-value="text">
<textarea name="" id="" cols="30" rows="10" ms-value="xxx{{text+‘!!!‘}}yyy"></textarea>
</div>
</body>
3, filter HTML, uppercase, lowercase, truncate, camelize, Escape, currency, number, date multi-filter work together, custom filter
From for notes (Wiz)
Avalon Video Learning Notes (ii)