Questions tagged [angular.js]
Code written using version 1 of the AngularJS open-source JavaScript framework. Use 'angular-2+' for code using later versions.
354 questions
26
votes
5
answers
2k
views
Cardshifter game lobby
We've been hard at work creating a browser-based GUI/Client for playing the Cardshifter TCG for the past week or so. Today, I just finished doing a pretty complicated layout for the chat lobby, along ...
22
votes
1
answer
15k
views
Simple Async Google Maps initializer with AngularJS
Here is a simple reusable AngularJS factory I came up with to initialize Google Maps Asynchronously, which somehow does not seem ...
21
votes
1
answer
15k
views
Draggable Resizeable Box
This is my first angular code. I've been working with jQuery for a while, so I don't have the same approach. I'm looking for advice and code improvement.
The following code has 3 directives:
...
15
votes
2
answers
14k
views
AngularJS - REST + Authentication service
I have a REST web service that uses OAuth 2 for authenticating and authorizing requests.
I have an endpoint, that when receiving the correct credentials, responds with an access token that will be ...
14
votes
2
answers
8k
views
AngularJS Todo List - too much controller logic?
I am starting an angular app and I was wondering if I am on the right track with this. I worked on my last angular app when I was just a youngun who didn't understand the important of designing the ...
14
votes
2
answers
296
views
FizzBuzzLizardSpock
I decided that since I was learning AngularJS and Bootstrap, I'd be remiss not to post a FizzBuzz, but FizzBuzz bores me, so I've extended it.
My version of FizzBuzz is configurable, and allows you ...
12
votes
2
answers
2k
views
Simple AngularJS controller for REST API
We record software builds from our build machine into a database and for practice purposes I'm building a little web dashboard for it.
The API is REST (WebApi) and provides access to query for ...
11
votes
1
answer
769
views
Hangman learning AI
I have been learning AngularJS and have written my first app. It's a Hangman AI which learns words and guesses the solution based on the words it knows.
Please look over my code and provide some ...
11
votes
1
answer
5k
views
A directive allowing to make a whole DOM subtree readonly
What do you think about this directive? For each input, it traverses the DOM towards the root and if it finds an element with the class ...
11
votes
1
answer
835
views
Handling Java instant Ajax request/respond with Angular
I am trying to build a food search app. I am using Angular and Spring. I am currently using the yelp API, but it's done on the Java side.
I think what I have achieved is really bad design. It works, ...
10
votes
1
answer
252
views
Baseball player statistics controller
I'm somewhat new to JavaScript and AngularJS, and read in Doug Crockford's book that hoisted function declarations can lead to issues. If you have any pointers on how to structure my file, those would ...
10
votes
2
answers
2k
views
Ionic REST + Authentication
I have an app that makes calls to the Podio API. The Podio Api uses OAuth2 protocol , after user's authenticate with their podio username and password an access and refresh token is provided for ...
10
votes
1
answer
7k
views
Browser resize service
In AngularJS, I currently have a directive and 2 services which permit me to bind the window resize event, and broadcast it to my application.
I would like to know if you could see anything that ...
9
votes
1
answer
945
views
Angular dropdown
I have created this little dropdown directive in Angular. The idea is that you create a nav element with a ul inside. The directive prepends a chevron and toggles ...
9
votes
1
answer
659
views
Animate and play sounds in Simon Says 'the Angular way'
I am a newbie coder and I'm trying to learn good coding habits. I'm making a Simon Says game challenge from Free Code Camp in Angular JS.
Codepen
I have an array that keeps random integers between ...
9
votes
1
answer
7k
views
Custom angular directive for data-binding on Telerik's Kendo UI
I am using Telerik's Kendo UI suite for a project, and was excited when they announced compatibility with Angular, but as I got a lot of code written I realized that they hadn't yet made the widget ...
8
votes
1
answer
2k
views
Hexadecimal to RGB conversion
I am trying to convert hex to rgb, and rgb to hex. My current code doesn't seem optimal, and there is an issue with 0's in the hexadecimal. What do you think about the overall quality of this code? ...
8
votes
3
answers
514
views
Handling shared state among a lot of elements in Angular
I am working on a project in Angular where I have a number of similar data objects. When you click on anyone of them it's state and amount of data shown will change. All of the objects start in the ...
8
votes
1
answer
662
views
Two AngularJS controllers for camera actions
I have the same functionality in two controllers and I want to refactor to place it in a shared method that both controllers can access. I was thinking on creating a separate service called "Camera" ...
8
votes
1
answer
12k
views
Dynamic routing with lazy load controllers
While trying to create an "admin" backend (to allow for CMS like functionality) to a site using AngularJS on the frontend, I came across an issue with routes.
In order to allow the admin to create ...
7
votes
2
answers
7k
views
In AngularJS, create lots of directives or use ng-controller?
This is a question about whether my coding style follows AngularJS best practices.
One of the selling points to Angular is directives. Directives allow you to create custom DOM with elements or ...
7
votes
2
answers
633
views
Beginner's Calculator code
I am trying to learn AngularJS as a start to my revival of learning, I think that I am getting the hang of it so far, but would like to see what I can do differently with some super simple ...
7
votes
1
answer
47k
views
Merging two arrays of objects with different keys/properties [closed]
I have two different arrays:
...
7
votes
1
answer
666
views
UI selector directives for an AngularJS invoicing module
I'm wrapping ui-select in my own directives to pre-configure and style it, as I need it for my app in different select widgets. They appear on many pages, for example ...
7
votes
2
answers
197
views
Interdependent color swatch widgets
To illustrate some algorithmic problems I found while writing this code review, I needed to include a live demonstration, which I implemented using a Stack Snippet with Angular.js.
The demonstration ...
7
votes
2
answers
6k
views
Dynamically load assets (CSS+images+controllers) on route resolve
I wrote a little factory to dynamically load assets in angular resolve. Is it well structured and can it be made prettier?
...
7
votes
1
answer
22k
views
AngularJS Tab Control
I'm experimenting with angular directives, and as a proof of concept I wanted to create a basic tab control. I'd like to know if anything can be changed to be more fluid, or if I'm doing things "right"...
7
votes
3
answers
196
views
Exposing a directive's computed variable
I have a directive called meetingList with its own isolated scope that receives a list of meetings and displays the filtered items based on some criteria. The ...
7
votes
1
answer
1k
views
AngularJs and Google Bot experiment
I have learned the question of solving Angular app optimization for search engines, and was frustrated that the most recommended option is prerendering HTML.
After some time spent, I suggested to ...
7
votes
1
answer
765
views
Open source angularjs pouchdb model persistence layer - release ready?
I'm considering releasing a library as a bower module. Are there issues with code quality, missing test cases, that need to be addressed first? Perhaps it's not a good candidate for public release. ...
7
votes
1
answer
2k
views
AngularJs Module Run Block, Configuration, and Route Definition
My AngularJs app is currently working fine. I'm working on modularity, refining my code design, and making it more readable. I have a app.js file that contains the ...
7
votes
1
answer
986
views
Datepickers for departure and return dates
I have to two datepickers. I want achieve the following functionality: the return date cannot be selected before the selected departure date and the departure date cannot be after the selected return ...
7
votes
1
answer
699
views
JavaScript/Angular TicTacToe Minimax AI
I am interested in getting some feedback on the code for my TicTacToe game, implemented with AngularJS, particularly with respect to the AI logic, which is printed below. (The full code base is ...
6
votes
2
answers
251
views
Profiles with profiling checkboxes
I have this HTML down below that creates a list with two columns, the left one containing profile information, and the right one containing checkboxes of the user feedback in a horizontal list.
The ...
6
votes
1
answer
2k
views
Improvements to an Angular ScrollSpy module
Things that I'm not sure about:
Whether this works in all use cases - alongside routing and within templates etc
Am I polluting the scope with all these variables? This seems to be the easiest way to ...
6
votes
2
answers
150
views
Optimize Game of Life
I'm a beginner at coding and the past days I tried to write the famous "Conway's Game of Life" in Angular.js. Right now I'm done with the code and the game works. But if the size of the ...
6
votes
2
answers
7k
views
Monkey patching angularjs controllers to have instance functions with injectables
In the spirit of Google's angular.js Style Guide, I set out to define my angularjs controllers as classes, complete with instance functions. I ran into trouble, however, when trying to access ...
6
votes
1
answer
916
views
Shopping cart simulator
I have tried to simulate a cart (only partially completed). I just wanted to see how the code upto this point can be enhanced. I am trying to learn about the usage of ...
6
votes
1
answer
232
views
Online store for pies - Part 1: Create your account to buy delicious pies
I've got a goal and that goal is to become an Angular expert. So what better way of learning than to create an online store for pies, right? I've just finished the registration part and would like ...
6
votes
1
answer
107
views
An object exposed to directives that need to track changes on it
This is an object exposed to the view and is being used on directives within the same view. The directives need to track changes on the ctrl.filters.applied object. ...
6
votes
1
answer
1k
views
Mocking dependencies when unit testing AngularJS services with QUnit
I'm trying to unit test an AngularJS service that is dependent on another service, using QUnit as my testing framework. The first test I'm writing is one to verify that my service calls another ...
6
votes
1
answer
3k
views
Asynchronous iterator for AngularJS
I wrote this as a convenient way to batch together multiple, repetitive AJAX calls. I was working in angular at the time, so I use the $q service, but I'm sure it ...
6
votes
1
answer
211
views
English-Russian irregular words tester
Could you please offer some suggestions about my self learning project?
It is really hard-coded, but I have no idea what to do next. I'm using angular (only few ...
6
votes
1
answer
3k
views
Angular JS Switcharoo multiple select module
I have created a script for going a multiple select option in Angular without using a select box that you have to hold control in order to select multiple items.
...
6
votes
2
answers
36k
views
JavaScript filter() on JSON object?
I'm building a web interface for a home monitoring sensor array, and fetching JSON from the backend framework. I want to start putting statistics together for monitoring different areas of the home, ...
6
votes
1
answer
685
views
Using setTimeout to get scrolling chat window to work, but doesn't feel like the ideal solution
My friend and I are working on a bare-bones chat web app, using Angular on the front end. He's using Swampdragon for some of the real-time stuff.
My task that I set out to achieve was to get the chat ...
5
votes
1
answer
3k
views
AngularJS constants depending on other constants - any established patterns?
I'd like to be able to define Angular constants in terms of other constants.
It's not possible to inject dependencies into Angular constant services. When I want ...
5
votes
1
answer
703
views
Angular promise in service
I'm new with Angular promise and I would like to know how to improve my code.
I have a service which preload media or data by calling an API.
The media API return an array of urls to preload.
...
5
votes
1
answer
4k
views
Angularjs extends service
As usual I'm wondering if there is a better way to do:
(The code extends a angular service)
...
5
votes
1
answer
128
views
Summarize JS Array more efficiently
I am working on a project for Udacity, where I should use CSV files to display data on fake corporate dashboard. Structure of the data I am working on is like this:
I am using AngularJS for this ...