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

ng-repeat嵌套 #22

Closed
Wscats opened this issue Sep 18, 2016 · 0 comments
Closed

ng-repeat嵌套 #22

Wscats opened this issue Sep 18, 2016 · 0 comments

Comments

@Wscats
Copy link
Owner

Wscats commented Sep 18, 2016

在ng-repeat中我们可以再嵌套一个ng-repeat
外层格式为ng-repeat="links in slides"
内层格式为ng-repeat="link in links track by $index"
注意要加上track by和索引值**$index**

<!DOCTYPE html>
<html ng-app="wsscat">
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <script src="../js/angular.js"></script>

    <body ng-controller="indexCtrl">
        {{name}}
        <div ng-repeat="links in slides">
            <hr/>
            <div ng-repeat="link in links track by $index">
                {{link}}
            </div>
        </div>
    </body>
    <script>
        var app = angular.module('wsscat', []);
        app.controller('indexCtrl', function($scope) {
            $scope.name = "wsscat";
            $scope.slides = [
                [1, 1, 1],
                [4, 5, 6],
            ];
        })
    </script>
</html>
@Wscats Wscats closed this as completed Dec 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant