Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="idea item" ng-repeat="item in items" isoatom>
- <div class="section comment clearfix" ng-repeat="comment in item.comments | range:1:2">
- ....
- </div>
- </div>
- myapp.filter('range', function() {
- return function(input, min, max) {
- min = parseInt(min); //Make string input int
- max = parseInt(max);
- for (var i=min; i<max; i++)
- input.push(i);
- return input;
- };
- });
- // This code throws the error "Duplicates in a repeater are not allowed.
- // Repeater: row in [1,1,1] key: number:1"
- <div ng-repeat="row in [1,1,1]">
- // This will work
- <div ng-repeat="row in [1,1,1] track by $index">
- $scope.customers = JSON.parse(data)
- <div ng-app="manyminds" ng-controller="MainCtrl">
- <div class="idea item" ng-repeat="item in items" isoatom>
- Item {{$index}}
- <div class="section comment clearfix" ng-repeat="comment in item.comments | range:1:2">
- Comment {{$index}}
- {{comment}}
- </div>
- </div>
- </div>
- angular.module('manyminds', [], function() {}).filter('range', function() {
- return function(input, min, max) {
- var range = [];
- min = parseInt(min); //Make string input int
- max = parseInt(max);
- for (var i=min; i<=max; i++)
- input[i] && range.push(input[i]);
- return range;
- };
- });
- function MainCtrl($scope)
- {
- $scope.items = [
- {
- comments: [
- 'comment 0 in item 0',
- 'comment 1 in item 0'
- ]
- },
- {
- comments: [
- 'comment 0 in item 1',
- 'comment 1 in item 1',
- 'comment 2 in item 1',
- 'comment 3 in item 1'
- ]
- }
- ];
- }
- <div ng-repeat="product in productList.productList track by $index">
- <product info="product"></product>
- </div>
- <div ng-repeat="product in productList.productList track by product.id">
- <product info="product"></product>
- </div>
- <div ng-repeat="product in productList.productList track by (product.id + $index)">
- <product info="product"></product>
- </div>
- {"items":
- [
- {
- "index": 1,
- "name": "Samantha",
- "rarity": "Scarborough",
- "email": "maureen@sykes.mk"
- },
- {
- "index": 2,
- "name": "Amanda",
- "rarity": "Vick",
- "email": "jessica@livingston.mv"
- }]
- }
- <select ng-model="list_views">
- <option ng-selected="{{view == config.list_view}}"
- ng-repeat="view in list_views"
- value="{{view}}">
- {{view}}
- </option>
- </select>
- <select ng-model="config.list_view">
- <option ng-selected="{{view == config.list_view}}"
- ng-repeat="view in list_views"
- value="{{view}}">
- {{view}}
- </option>
- </select>
- Repeater: {0}, Duplicate key: {1}, Duplicate value: {2}
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta charset="utf-8" />
- <title></title>
- <script src="angular.js"></script>
- </head>
- <body>
- <div ng-app="myApp" ng-controller="personController">
- <table>
- <tr> <th>First Name</th> <th>Last Name</th> </tr>
- <tr ng-repeat="person in people track by $index">
- <td>{{person.firstName}}</td>
- <td>{{person.lastName}}</td>
- <td><input type="button" value="Select" ng-click="showDetails($index)" /></td>
- </tr>
- </table> <hr />
- <table>
- <tr ng-repeat="person1 in items track by $index">
- <td>{{person1.firstName}}</td>
- <td>{{person1.lastName}}</td>
- </tr>
- </table>
- <span> {{sayHello()}}</span>
- </div>
- <script> var myApp = angular.module("myApp", []);
- myApp.controller("personController", ['$scope', function ($scope)
- {
- $scope.people = [{ firstName: "F1", lastName: "L1" },
- { firstName: "F2", lastName: "L2" },
- { firstName: "F3", lastName: "L3" },
- { firstName: "F4", lastName: "L4" },
- { firstName: "F5", lastName: "L5" }]
- $scope.items = [];
- $scope.selectedPerson = $scope.people[0];
- $scope.showDetails = function (ind)
- {
- $scope.selectedPerson = $scope.people[ind];
- $scope.items.push($scope.selectedPerson);
- }
- $scope.sayHello = function ()
- {
- return $scope.items.firstName;
- }
- }]) </script>
- </body>
- </html>
- $http({
- method: 'GET',
- url: url, // your remote url
- responseType: "json"
- }).
- then(function successCallback(response) {
- //your code when success
- }, function errorCallback(response) {
- //your code when fails
- });
- <li ng-repeat='name in stafflist track by $index'>{{name}}</li>
Add Comment
Please, Sign In to add comment