Avalon Video Learning Notes (ii)

Source: Internet
Author: User

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}}
  
 
  1. <meta charset="UTF-8">
  2. <title>avalon-prop</title>
  3. <script type="text/javascript" src="../avalon.min.js"></script>
  4. <script>
  5. avalon.ready(function () {
  6. avalon.define({
  7. $id:"test",
  8. word:"Hello avalon"
  9. })
  10. avalon.scan();
  11. })
  12. </script>
  13. <body>
  14. <div ms-controller="test">
  15. {{word}}
  16. </div>
  17. </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?
 
   
  
  1. <style>
  2. .ms-controller{
  3. visibility:hidden;
  4. }
  5. </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:
 
   
  
  1. avalon.config({
  2. interpolate:["[","]"]
  3. })
  
 
  1. <meta charset="UTF-8">
  2. <title>avalon-prop</title>
  3. <script type="text/javascript" src="../avalon.min.js"></script>
  4. <script>
  5. avalon.config({
  6. interpolate:["[[","]]"]
  7. })
  8. avalon.ready(function () {
  9. avalon.define({
  10. $id:"test",
  11. word:"Hello avalon"
  12. })
  13. avalon.scan();
  14. })
  15. </script>
  16. <body>
  17. <div ms-controller="test">
  18. [[word]]
  19. </div>
  20. </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
  
 
  1. <meta charset="UTF-8">
  2. <title>avalon-prop</title>
  3. <script type="text/javascript" src="../avalon.min.js"></script>
  4. <script>
  5. avalon.ready(function () {
  6. avalon.define({
  7. $id:"test",
  8. word:"Hello avalon"
  9. })
  10. avalon.scan();
  11. })
  12. </script>
  13. <body>
  14. <div ms-controller="test" ms-text="word"></div>
  15. </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.
  
 
  1. <meta charset="UTF-8">
  2. <title>avalon-prop</title>
  3. <script type="text/javascript" src="../avalon.min.js"></script>
  4. <script>
  5. avalon.ready(function () {
  6. avalon.define({
  7. $id:"test",
  8. word:"<p>Hello avalon<p>"
  9. })
  10. avalon.define({
  11. $id:"test2",
  12. word:"<p>Hello avalon</p>"
  13. })
  14. avalon.scan();
  15. })
  16. </script>
  17. <body>
  18. <div ms-controller="test" ms-text="word"></div>
  19. <div ms-controller="test2" ms-html="word"></div>
  20. </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.
  
 
  1. <meta charset="UTF-8">
  2. <title>avalon-prop2</title>
  3. <script type="text/javascript" src="../avalon.min.js"></script>
  4. <script type="text/javascript">
  5. avalon.ready(function () {
  6. avalon.define({
  7. $id:"text",
  8. text:‘111‘
  9. })
  10. avalon.scan();
  11. })
  12. </script>
  13. <body>
  14. <div ms-controller="text">
  15. <input type="text" ms-value="text">
  16. <textarea name="" id="" cols="30" rows="10" ms-value="xxx{{text+‘!!!‘}}yyy"></textarea>
  17. </div>
  18. </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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.