6
votes
Baseball player statistics controller
Bearing in mind that you claim that you do not to maintain this code anymore1, there are a few suggestions I would have about this code:
define functions and accept parameters- that should allow the ...
4
votes
Grab the first 4 items that meet the condition from a data set with an unknown size
So that would mean that very large datasets would increase computation time.
You should ask if very large datasets are possible. Because if they're not, clean code takes precedence over what would ...
4
votes
Accepted
Returning the results of four $resource calls as a JSON array in AngularJS
Never, and I mean NEVER, manually construct JSON. That's just asking for trouble. Construct the object then use JSON.stringify. FYI, arrays are valid JSON so you ...
3
votes
Accepted
Communication to Child Controller
Having to refer to $scope.$parent is absolutely bad-practice, because dependencies will go up and down and all sorts of ways in your application. It will become a ...
3
votes
Accepted
Particle text directive
There's a few files so I'll focus on a more general code review.
Overall it looks good! The code is well structured, readable and your logic is easy to follow.
ES6+
You're already using newer ...
3
votes
Accepted
Move an element up / down an array in Javascript
What you are doing isn't very efficient. First you remove the element from the array, and to close the gap, every single element after it has to move position. Then you insert the element again, and ...
2
votes
Unit tests for a single JavaScript function
You can use array.map to create errs instead of creating an array and pushing to it.
...
2
votes
File upload in AngularJS causes browser out of memory error
Marshaling the file contents as a byte array is obviously problematic.
Browsers can easily upload files through HTML forms, with
...
2
votes
Accepted
Generating a list of menus with AngularJS
Simple answer, no it's not OK this way, you are totally misusing the angular.js purpose.
Anugular.js is a framework in which follows a modular pattern, it was designed by the time web wasn't so rich ...
2
votes
Simple angular app - Shopping website
I noticed that you have a spot for controllers, but then in your directive you declare a function for the Controller Attribute instead of using a controller that you have already at your disposal from ...
2
votes
Splice from Array if index matches
A while back, I went through these exercises about functional programming in JS and since then I strive to use those techniques whenever possible. Bear in mind that functional techniques can lead to ...
2
votes
Grab the first 4 items that meet the condition from a data set with an unknown size
A functional approach to breaking out of a loop is to use Array.some(). It would be different than using .reduce() because the ...
2
votes
Accepted
AngularJS - Making Factory and Controllers DRY
One option is to make the function returned by the factory listDataService accept a parameter for the getbytitle() value:
...
2
votes
Collecting a list of documents from a factory for an AngularJS controller
In addition to what Blindman said, I would recommend avoiding using this in nested scopes , which is always confusing and error prone, by assigning ...
2
votes
Accepted
Collecting a list of documents from a factory for an AngularJS controller
Specify this context
I support Blindman67's answer. If arrow functions were not supported by all browsers used (e.g. IE - but then again there is little support ...
2
votes
Accepted
Laravel Single Page Application Using Angular Js
This code seems okay for the most part - I don't see any major flaws with the code, just a few things that I will critique below.
Despite being spread across quite a few files, this code seems pretty ...
2
votes
Accepted
Script to load controllers dynamically for AngularJS
Feedback
This is an interesting way of loading controllers. I like the application of the promises. It does feel a little weird not to have an ng-app directive but ...
2
votes
Accepted
show/hide components
You can use Bracket Notation to have custom object key by ['text'+variable].
...
2
votes
Accepted
Create objects corresponding to whichever field has value from among a list of fields
This
const int STATUS_BASE = 1;
const int STATUS_FIN = 2;
const int STATUS_FINI = 3;
const int STATUS_WAST = 4;
const int STATUS_PRGR = 5;
screams for an enum ...
2
votes
Accepted
Selecting/ Deselecting All from Checkbox
I see what looks like a bug. The x variable (which should probably be renamed to something more informative - maybe user?) is a ...
1
vote
Traverse and modify a deep object
This looks like a very good fit for JSONPath (initial specification, list of libraries).
Of course, if you only have this single code part which has to do traversing/modifying in a JSONPath-like ...
1
vote
Traverse and modify a deep object
You could move the logic that gets each panel / screen etc into it's own function, and remove some of the indenting, like so:
...
1
vote
Accepted
Managing JS objects while preserving references
Instead of checking each property in the result to see whether it was in the source object, simply delete all of the properties in the destination object and then use ...
1
vote
Splice from Array if index matches
Here's what functional style might look like. Unfortunately, it requires index recalculation, and overall more verbose and complicated, even though it tries to go the ".some()" way. :)
I believe it's ...
1
vote
Using chartJS in Angularjs to plot IOT data
Feedback
The code appears to make good use of AngularJS and ChartJS, as well as promises.
For the function that handles the response, I had to move the line that assigns response.data to $scope....
1
vote
Accepted
Unit tests for a single JavaScript function
I would say that, of course, the first version when you split your tests into granular logical blocks is much better and far more explicit.
There is even a practice to have a single assertion per ...
1
vote
Accepted
Tying the enablement of one checkbox to another using AngularJS and jQuery
Is there an obvious cleaner way of doing this [?]
Without knowing where the element(s) with class name inklogin exist, it can only be presumed that it exists as a child of the element with ...
1
vote
Accepted
Step by step wizard
You code does seem to work without !important. Here is the plunker demonstrating.
To better organize your css you could use SMACSS, BEM, OOCSS or some custom ...
1
vote
Use counter for ajax loader
You SHOULD consider migrating to Angular (aka Angular2, aka Angular5) from ANgularJS (version 1), as it's not developing and soon won't be supported anymore.
I guess nested promises would be much ...
1
vote
Getting hex colours from a image
General feedback
There are a few ways that some of the loops can be simplified (see below). These may or may not improve the high CPU issue.
The code makes some repeated calls to functions with the ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
angular.js × 355javascript × 326
html × 43
promise × 21
beginner × 20
controller × 13
jquery × 12
json × 12
css × 11
performance × 10
coffeescript × 9
array × 8
html5 × 8
ajax × 8
datetime × 7
node.js × 7
validation × 7
ecmascript-6 × 7
asynchronous × 7
typescript × 7
twitter-bootstrap × 7
error-handling × 6
mvc × 6
cordova × 6
game × 5