Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议增加ms-repeat功能 #154

Closed
xw332 opened this issue Nov 15, 2013 · 1 comment
Closed

建议增加ms-repeat功能 #154

xw332 opened this issue Nov 15, 2013 · 1 comment

Comments

@xw332
Copy link

xw332 commented Nov 15, 2013

最简单的应用场景是一个ul的商品列表,显示的数据可能是从三个数组里抽出来的,如果用ms-each不得不增加三个仅用于循环的父级标签

<ul>
  <ul ms-each="arr1">
    <li>test</li>
  </ul>
  <ul ms-each="arr2">
    <li>test</li>
  </ul>
</ul>

有ms-repeat的话三个数组自己循环就行了,不会影响标签的层级

<ul>
  <li ms-repeat="arr1">test</li>
  <li ms-repeat="arr2">test</li>
</ul>
@RubyLouvre
Copy link
Owner

<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="UTF-8">
        <title>ms-repeat</title>
        <script src="avalon.mobile.js" type="text/javascript"></script>        
        <script>
            var model = avalon.define("xxx", function(vm) {
                vm.array = [2, 3, 1, 7, 4]
            })
            setTimeout(function() {
                model.array.splice(2, 1, "aaa")
            }, 1000)
            setTimeout(function() {
                model.array.sort()
            }, 3000)
            setTimeout(function() {
                model.array.clear()
            }, 5000)
        </script>
    </head>
    <body ms-controller="xxx">
        <h1>ms-repeat</h1>
        <p>用法与ms-each一致,ms-repeat-el?-index?,后两个参数可选 </p>
        <ul>
            <li ms-repeat="array">{{el}} ---- {{$index}}</li>
        </ul>
    </body>
</html>

7450715

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants