ng-repeat

ng-hide or ng-show does not work if its controlled from within a ng-repeat

我只是一个虾纸丫 提交于 2019-12-13 02:34:26
问题 I am trying to hide the div if any of the buttons in the ng-repeat is clicked. However it doesn't seem to work, it leads me to think if ng-hide or ng-show won't work if it is controlled from within a ng-repeat? <div data-ng-hide="showChooseHardware"> <table class="table"> <tbody> <tr data-ng-repeat="hardware in hardwares"> <td>{{hardware.name}}</td> <td> <button type="button" class="btn" data-ng-click="showChooseHardware=!showChooseHardware"/> </td> </tr> </tbody> </table> </div> 回答1: This is

AngularJS ng-repeat applied multiple times in $compiled directive

邮差的信 提交于 2019-12-12 21:27:09
问题 I've written a directive that dynamically creates a popover for an element: app.directive('popover', function($compile, $timeout){ return { link: function(scope, element, attrs) { $timeout(function() { // grab template var tpl = $(element).find('.popover-template') // grab popover parts of template var template = { //$compile( $(element).siblings(".pop-content").contents() )(scope) title: tpl.find('.template-title').contents(), content: tpl.find('.template-content').contents() }; // render

AngularJS tabs with ng-repeat

本小妞迷上赌 提交于 2019-12-12 09:49:57
问题 I asked this question before and was wondering maybe somebody has had a similar problem and maybe know how to deal with it? My plnkr! Angular tabs are not working with ng-repeat. It seems that Angular can't put together tab value from click and tab value from ng-show. My code: <section ng-app="myApp"> <div ng-controller="myCtrl"> <ul ng-init="tab=1"> <li ng-repeat="item in data"> <a href ng-click="tab = item.thingy">{{item.name}}</a> </li> </ul> <div ng-repeat="item in data" ng-show="tab ===

How to pass multiple parameter in angular filter function, not custom filter

青春壹個敷衍的年華 提交于 2019-12-12 08:28:35
问题 I tried hard and visit lot of similar question like this but still unable to solve this issue. I want to pass extra parameter in angular filter function. I found solution as below but it's not working. I am getting undefined for object which I have used in ng-repeat . <li ng-repeat="user in users | filter:isStatus(user,secondParam)">{{user.name}}</li> There are solution for angular custom filter as below but that also not working with angular filter function. <li ng-repeat="user in users |

ng-repeat show only last element

半城伤御伤魂 提交于 2019-12-12 07:46:20
问题 I am developing inbox for messages with AngularJs, and I came across one issue: I want to show only last element within ng-repeat . I did some research, and found out that the code below should work. <div class="inbox" ng-repeat="recipient in messages"> <ul> <div> <span> {{recipient.$id}} <br> </span> <li class="inboxItem"> <span ng-repeat="messages in recipient"> {{messages.sender}} {{messages.message}} <br></span> </li> </div> </ul> </div> However, it does not. Can you guys tell me what am

ng-repeat (iterate) over complex json object in Angular

早过忘川 提交于 2019-12-12 06:19:21
问题 One controller returns me a very complex json object: { "184": { "title": "THE STONE ROSES", "sessions": { "1443564000000": { "num": 5 }, "1442959200000": { "num": 1 }, "1447196400000": { "num": 1 }, "1444428000000": { "num": 2 }, "1446332400000": { "num": 3 } } } } I have tried to iterate over it on my view like this <div class="large-6 columns" ng-repeat="item in showItems" st-raw> <h1>{{item.sessions}}</h1> </div> with this code I get part if the object printed on the html response: {

AngularJS ng-repeat key, value pair access key on group by multiple fields

强颜欢笑 提交于 2019-12-12 05:27:53
问题 I'm new to Angular and would like to learn the best way to handle a problem. I want to access keys in my first ng-repeat grouped by multiple columns. <table width="100%" style="text-align: center;" data-role="table" data-mode="" class="ui-responsive ui-shadow"> <thead> <tr> <th>Id</th> <th>Course</th> <th>Module</th> <th>Subject</th> <th>Toc</th> <th>Chapter</th> <th>Activity Done</th> <th>Start</th> <th>End</th> <th>Time Spent</th> </tr> </thead> <tbody ng-repeat="(key, value) in sessions |

How to create a space between angular ng-repeated divs in jade?

不打扰是莪最后的温柔 提交于 2019-12-12 03:44:31
问题 The code is: .container my-directive(ng-repeat="item in items", item="item") My goal is to use that space with justify to create an evenly spaced grid of an unknown number of divs. 回答1: It seems the issue is with ng-repeat . Here's a jade solution: .container my-directive(ng-repeat-start="item in items", item="item") span(ng-repeat-end) #{' '} Here's an equivalent solution for HTML I found: https://stackoverflow.com/a/19507046/4760334 来源: https://stackoverflow.com/questions/39026435/how-to

angularjs, $compiled templates and ng-repeat

北战南征 提交于 2019-12-12 03:37:20
问题 Essentially, I take two templates inside a compile function of a directive. I compile them once and for all (via $compile) in the compile phase of the directive. In the link phase of the directive, I watch a scope variable and applies one or the other compiled template to the scope. testApp.directive('testField', ['$compile', function ($compile) { return { restrict: 'E', scope: true, compile: function(tElement, tAttrs) { var viewFn = $compile("<div>View: <span ng-repeat='x in [1,2,3]'>{{x}}<

Using filter to create array, then using that array to filter ng-options

那年仲夏 提交于 2019-12-12 03:36:31
问题 I am using isteven-multi-select to output an array of objects from a select element's multiple selections. [ { category: "Adventure", ticked: true }, { category: "Strategy", ticked: true } ] 2. Then using angular.forEach to change the array of objects into an array of the category values. $scope.testOutput = function () { angular.forEach($scope.output, function(value, prop, obj) { var categoryFiltered = []; categoryFiltered.push(value.category); console.log(categoryFiltered); }); };