ng-repeat

dupes in angular when using ng-repeat

会有一股神秘感。 提交于 2019-12-11 06:22:29
问题 I'm new to Angular and ng-repeat isnt working for me. My first ng-repeat works but the second one where im using a json string isn't. Its complaining about ng-repeat dupes but I dont understand why. What I'm I doing wrong? see the code here JSFiddle or here: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="utf-8" /> <title>test</title> </head> <body> <div ng-app ng-controller="AController"> <ul> <li ng-repeat="item in firstTest"> {{item}} </li> </ul> <hr />

Change scope value on ng-click

前提是你 提交于 2019-12-11 06:04:41
问题 I would like to use tabs to hide and show items in an ng-repeat. Is it possible to change the value of a scope like so? <a ng-click="packageType = '1'">Package 1</a><a ng-click="packageType ='2'">Package 2</a><a ng-click="packageType = '3'">Package 3</a> <div ng-repeat="item in packages" ng-show="packageType >=item.packageID"> {{item.name}}</div> and the scope: $scope.packages = [...{ "name": "some name", "packageID": 1}...] Where packageID can be 1, 2 or 3? 回答1: Here's the code that does

Angular 1: ng-repeat throws infdig error

痴心易碎 提交于 2019-12-11 05:39:14
问题 Controller: (function(angular) { var app = angular.module('t2w'); app.factory('httpq', function($http, $q) { return { get: function() { var deferred = $q.defer(); $http.get.apply(null, arguments).success(deferred.resolve).error(deferred.resolve); return deferred.promise; } } }); app.controller('JobsCtrl', ['$scope','httpq','baseUrl', function($scope, httpq, baseUrl) { httpq.get(baseUrl + '/jobs/json').then(function(data) { $scope.jobs = data; }).catch(function(data, status) { console.error(

Angular ng-repeat filter running before data retrieved

浪子不回头ぞ 提交于 2019-12-11 03:55:01
问题 I have a list of appointments that I need to filter by staff member. I am pulling the appointments from a database using a Breeze controller. Some appointments have multiple staff members involved, so I need to drill into a child entity of the appointment to find the staff members for each appointment. I am trying to show a list based on the staff member selected elsewhere using ng-repeat and a filter as follows: <section data-ng-repeat="appt in apptCtrl.appointmentList | filter: apptCtrl

Angularjs ng-repeat running total based on value

自闭症网瘾萝莉.ら 提交于 2019-12-11 02:39:12
问题 Working in angularjs and looking to keep a running total based on a value retrieved from the data. The following code always returns the full total value for all items. <div ng-repeat="child in pItem.childItems | orderBy:'displayOrder'" ng-init="$parent.totalValue = $parent.totalValue + child.field[0].value"> Changing that from the parent scope to the child clears the totalValue on each repeat. So the value always equals the child value just for that one item. I'm looking for something which

Ng-repeat for nested object without nested ng-repeat

耗尽温柔 提交于 2019-12-11 02:36:38
问题 i created following plunker for my problem: http://plnkr.co/edit/dkpFKU <body ng-controller="MainCtrl"> <select ng-model="selected" ng-options="t.thickness for t in products[0].wood"></select> <div ng-repeat="product in products[0].wood |filter:{'thickness': selected.thickness}" > <ul> <li ng-repeat="tex3 in product.textures"> <h6 class="center"> <small>{{tex3.texture}}</small> </h6> </li> </ul> </div> $scope.products = [ { "cat": "Product Category", "subcat_id": 1, "cat_id": 1, "ime":

ng-repeat not showing list of JSON array in AngularJS 1.5, but I can see values individually

空扰寡人 提交于 2019-12-11 00:58:55
问题 I'm using a REST architecture on the backend using CakePHP 3 that returns a JSON Array with this format according to firebug, it's a 200 OK, with this response: { "recipes": [ { "id": 0, "name": "modificadodsadasdas" }, { "id": 1, "name": "dasdasdasdasdas" } ] } My index.html file: <html> <head> </head> <body ng-app="AppRecetas"> <div ng-controller="RecetasCtrl"> <ul ng-repeat="recipe in recipes"> <li>{{recipe.name}}</li> </ul> </div> <script src="js/angular.min.js"></script> <script src="js

angular Way of: show or hide element after button click

百般思念 提交于 2019-12-10 19:04:13
问题 I am pretty new to angular and i cant get it right. inside the following example i am trying to show the answer to a question after the user clicks on the corresponding button. before the answer is shown i want to run a function that checks if the user has the privilege to reveal the answer. in the example i assume he has the rights. what i have to do to to remove the "ng-hide" class in the row where the button was clicked. i appreciate any kind of help. thanks in advance var myApp = angular

AngularJS ng-repeat to populate grid from array

徘徊边缘 提交于 2019-12-10 18:30:45
问题 Thanks in advance for reading. I am trying to utilize angular's ng-repeat to render objects from an array into an Nx3 Table. For the sake of example let's consider a 3x3 table. Here is a simplified example of the array: objects = [{"text": "One, One"},{"text": "One, Two"},{"text": "One, Three"}, {"text": "Two, One"},{"text": "Two, Two"},{"text": "Two, Three"}, {"text": "Three, One"},{"text": "Three, Two"},{"text": "Three, Three"}]; The "text" field describes where in the 3x3 grid matrix each

directive can not ''require:ngRepeat'

こ雲淡風輕ζ 提交于 2019-12-10 17:38:10
问题 I write below directive to make call a function when ngRepeat element gets rendered on UI. Directive directives.directive('repeatDone', function() { return { restrict: 'A', require: 'ngRepeat', link: function(scope, element, attrs, ngModel) { if (scope.$last) { scope.$eval(attrs.repeatDone); } } }; }); But it is giving $compile error. If I remove require part, it works OK. Why AngularJS can not accept "require: 'ngRepeat'"? Help would appreciated. 回答1: require is used for accessing the