How would I use AngularJS ng-repeat with Twitter Bootstrap's scaffolding?

前端 未结 5 1993
既然无缘
既然无缘 2020-12-24 12:39

How would I use AngularJS ng-repeat to display the following HTML (Twitter Bootstrap Scaffolding)? Essentially, every third record I need to close the <

5条回答
  •  情歌与酒
    2020-12-24 12:57

    A more elegant way is to use the view model to provide a chunked collection and then let the view handle it like

    Projects
    Projects {{project}}

    and the coffeescript is pretty simple

    # Break up an array into even sized chunks.
    chunk = (a,s)->
        if a.length == 0
            []
        else               
            ( a[i..i+s-1] for i in [0..a.length - 1 ] by s)
    
    @Controller = ($scope)->
        $scope.projects = "ABCDEF"
    
        $scope.$watch "projects", ->      
           $scope.rows = chunk $scope.projects.split(""), 3
    
    angular.bootstrap(document, []);
    

    http://jsfiddle.net/ADukg/370/

提交回复
热议问题