angularjs-ng-repeat

Angular - Filter to remove blank strings from array

假如想象 提交于 2019-12-30 11:54:09
问题 I have an object of arrays... The array can contain blanks, how can i create an ANgular filter to remove the blanks to determine the length of the array? $scope.myData = { ["1", "1", "4", "4", "N", "4", "6", "8", "", "", "", "", "", "", "", "", "", "", ], ["2", "2", "4", "6", "0", "6", "5", "4", "2", "", "8", "", "", "", "", "", "", "", ], ["2", "3", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", ], ["3", "F", "D", "3", "5", "1", "D", "5", "", "", "", "", "", "", "", "", "",

AngularJS – append row after element in directive

跟風遠走 提交于 2019-12-30 08:17:12
问题 My question is similar as this one, but instead of prepending row, I want it to append. This doesn’t work: app.directive('createTable', function ($compile) { return { link: function (scope, element, attrs) { var contentTr = angular.element('<tr><td>test</td></tr>'); contentTr.parentNode.insertBefore(element, contentTr.nextSibling); $compile(contentTr)(scope); } } }); 回答1: This does the job: app.directive('createTable', function ($compile) { return { link: function(scope, element, attrs) { if

Conditionally apply filters with ng-repeat

早过忘川 提交于 2019-12-30 06:11:09
问题 I have an object that contains a mixture of numbers and text for values. I'd like to apply the numbers filter to the object's value when it's a number (obviously). But when it isn't a number, I'd be okay with it just spitting out the string. As is, applying | number to the value formats the numbers, but leaves the string values empty (afterall, they aren't numbers). I'm guessing it'll have to be a custom filter (which I have yet had a need to make). Is there a way to do it solely within the

Conditionally apply filters with ng-repeat

*爱你&永不变心* 提交于 2019-12-30 06:11:07
问题 I have an object that contains a mixture of numbers and text for values. I'd like to apply the numbers filter to the object's value when it's a number (obviously). But when it isn't a number, I'd be okay with it just spitting out the string. As is, applying | number to the value formats the numbers, but leaves the string values empty (afterall, they aren't numbers). I'm guessing it'll have to be a custom filter (which I have yet had a need to make). Is there a way to do it solely within the

Angular Directive Does Not Evaluate Inside ng-repeat

巧了我就是萌 提交于 2019-12-30 02:12:08
问题 I have the following setup: App/Directive var app = angular.module("MyApp", []); app.directive("adminRosterItem", function () { return { restrict: "E", scope: { displayText: "@" }, template: "<td>{{ displayText }}</td>", // should I have this? link: function(scope, element, attrs){ // What do I put here? I don't seem to have any // element to initialize (set up event handlers, for example) }, compile: function(?,?,?){} // should I have this? If so, what goes inside? } }); Controller function

angular ng-repeat skip an item if it matches expression

余生颓废 提交于 2019-12-29 11:31:47
问题 I'm looking for a way to basically tell angular to skip an item in an ng-repeat if it matches an expression, basically continue ; In controller: $scope.players = [{ name_key:'FirstPerson', first_name:'First', last_name:'Person' }, { name_key:'SecondPerson', first_name:'Second', last_name:'Person' }] Now in my template I want to show everyone that doesn't match name_key='FirstPerson' . I figured it has to be filters so I setup a Plunkr to play around with it but haven't had any luck. Plunkr

How to expand/collapse all rows in Angular

自古美人都是妖i 提交于 2019-12-29 08:22:25
问题 I have successfully created a function to toggle the individual rows of my ng-table to open and close using: TestCase.prototype.toggle = function() { this.showMe = !this.showMe; } and <tr ng-repeat="row in $data"> <td align="left"> <p ng-click="row.toggle();">{{row.description}}</p> <div ng-show="row.showMe"> See the plunkr for more code, note the expand/collapse buttons are in the "menu". However, I can't figure out a way to now toggle ALL of the rows on and off. I want to be able to somehow

How to expand/collapse all rows in Angular

非 Y 不嫁゛ 提交于 2019-12-29 08:22:08
问题 I have successfully created a function to toggle the individual rows of my ng-table to open and close using: TestCase.prototype.toggle = function() { this.showMe = !this.showMe; } and <tr ng-repeat="row in $data"> <td align="left"> <p ng-click="row.toggle();">{{row.description}}</p> <div ng-show="row.showMe"> See the plunkr for more code, note the expand/collapse buttons are in the "menu". However, I can't figure out a way to now toggle ALL of the rows on and off. I want to be able to somehow

Dynamic orderBy in AngularJS

我的梦境 提交于 2019-12-29 07:45:50
问题 I have an array of objects I want to order dynamically, based on a value from a drop down menu. This is what I have so far in my list: ng-repeat="item in filteredItems = (items | filter:searchInput | orderBy:canBeAnything)" But the problem however is that the sorting can be an attribute of the object or a calculated value using a function. It also should be able to sort in a descending way (optionally). I know I can use a string for the canByAnything variable behind the orderBy passing an

How do I properly ng-repeat through nested key value pairs in angularJS

末鹿安然 提交于 2019-12-29 07:35:16
问题 View live code: Angular JS How in the world do I properly loop through nested key value pairs and properly output them like below? View I want is a tree like so -touts -classes -col-12 -col-md-12 -col-lg-12 Currently the view is: touts {"classes":["col-12","col-md-12","col-lg-12"]} JS: var currentApp = angular.module('currentApp', []); currentApp.controller('ACtrl', function($scope){ $scope.templates = { 'touts' : [ { 'classes' : ['col-12', 'col-md-12', 'col-lg-12' ] } ] }; }); HTML: <div ng