1

I would like to show three lists horizontally. Can anyone give me some hints if using angularjs?

This is I want to show in the page:

  List1              List2             List3

*list1_item1     *list2_item1        *list3_item1
*list1_item2     *list2_item2        *list3_item2
*list1_item3     *list2_item3        *list3_item3

There are also some boundary lines shown among lists.

Thanks

1
  • nothing different than any other angular. WHat is the specific problem Commented Jan 27, 2015 at 21:40

3 Answers 3

3

Use ng-repeat for each of three horizontally placed divs and put the list in.

Sign up to request clarification or add additional context in comments.

Comments

0

You can user this with pure CSS. Just float your div's to the left. If you are required use an ng-repeat like

<div ng-repeat="list in lists">
     <li ng-repeat="item in list"> {{item.name}} </li>
</div>




<div style="float:left;">
    <h1>LIST ITEM 1</h1>
    <li>list1_item1 </li>
    <li> list1_item2 </li>
    <li> list1_item3 </li> 
  </div>

  <div style="float:left">
    <h1>LIST ITEM 2</h1>
    <li>list2_item1 </li>
    <li> list2_item2 </li>
    <li> list2_item3 </li> 
  </div>

  <div style="float:left;">
    <h1>LIST ITEM 3</h1>
    <li>list3_item1 </li>
    <li> list3_item2 </li>
    <li> list3_item3 </li> 
  </div>

Here is a plunkr for it.

http://plnkr.co/edit/WmQHQCQtn6b4kb7EFtvz?p=preview

Comments

0

What you are looking for is the NgRepeat directive and just 3 divs with some simple css.

Here is a little demo of what you want. Code Pen

HTML

<h3>Three Lists</h3>
<div ng-app="threeListsApp" ng-controller="ctrl">
  <ul>
    <div class="itemClmn">
      <h4>items A</h4>
      <p ng-repeat="(country,goals) in itemsA">{{country}} : {{goals}}</p>
    </div>
    <div class="itemClmn">
      <h4>items B</h4>
      <p ng-repeat="bItem in itemsB">{{bItem.name}}: {{bItem.gender}}</p>
    </div>
    <div class="itemClmn">
      <h4>items C</h4>
      <p ng-repeat="cItem in itemsC">{{cItem[0]}}: {{cItem[1]}}</p>
    </div>
  </ul>
</div>

CSS

.itemClmn
{
  position: relative;
  float: left; 
  width: 130px;
}

JS

var a = {
    "India": "2",
    "England": "2",
    "Brazil": "3"
};
var b = [{
    name: "Jim",
    gender: "M"
}, {
    name: "Jane",
    gender: "F"
}, {
    name: "Robyn",
    gender: "F"
}];
var c = [
    ["Blue", "1"],
    ["Green", "2"],
    ["Red", "3"]
];

angular
.module('threeListsApp', [])
.controller('ctrl', ['$scope', function ($scope) {
    $scope.itemsA = a;
    $scope.itemsB = b;
    $scope.itemsC = c;
}]);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.