Latest Angular.js Recipes

Execute method with Angular's $timeout in a for loop

I'm learning AngularJS.

What I want to do is execute a method in a for loop with $timeout.

Here is example:

for(var i = 0; i < 10; i++) {
    $timeout(function(i) {
    }, 1000);

function someMethod(i) {

Read the entire recipe Recipe added 36 minutes ago

Ionic and AngularJS - Drag element and move it around - how to get mouse position?

So I'm trying to have a HTML element dragged around the page with my finger (or mouse, on desktop). The element is hidden at first, three other are shown, and when dragging one of them the hidden element reveals and moves with the finger - the initial...

Read the entire recipe Recipe added 1 hour, 42 minutes ago

Force image orientation angularjs

I have this odd behavior when I upload an image and if this image size has more height than with I get the image rotated 90 degrees.

check this fiddle that's using ngImgCrop and this is the image that I'm uploading

the code of the ngDmgCrop it's...

Read the entire recipe Recipe added 2 hours, 39 minutes ago

How to change height of ui-grid row?

I am using ui-grid. I have a lot of rows and that is why I use scrolling. Everything works perfectly ok until I try to change the height of the rows. Then the scrolling becomes a mess. I have added an example here ...

Read the entire recipe Recipe added 3 hours, 37 minutes ago

AngularJS - Value attribute on an select/dropdownlist is ignored when there is a ng-model used

My question is very similar to this one : AngularJS - Value attribute on an input text box is ignored when there is a ng-model used?

Considering that answer :

I would like to know if there's a way to do...

Read the entire recipe Recipe added 4 hours, 43 minutes ago

Angularjs on page load call function

I am learning AngularJS. I have some article tag and on clicking on a button each article page is showed without any page refresh. This is one page website. What I want is that when article id "showSelector" is loaded I want to call myFunction() and...

Read the entire recipe Recipe added 5 hours, 40 minutes ago

AngularJS: How to have default nested state using UI Router?

I currently have a root index.html with a single ui-view which gets replaced depending on which "page" the user is on, e.g. Books, Games etc. Taking the Books page as an example, this view has content that I'd like to display on all pages which are...

Read the entire recipe Recipe added 6 hours, 37 minutes ago

Download a file protractor test case

I am writting a potractor test case to download a file which can be any type.

  senario:To download a file
  Step 1-click on the downloadlink
  Step 2-check whwther the file is downloaded or not

how do i now check that the file is downloaded...

Read the entire recipe Recipe added 7 hours, 36 minutes ago

Using multiple radio buttons to filter ng-repeat boolean object properties

I have json data array of Carpet objects (see plunker)

  designerApp.controller('CarpetCtrl', ['$scope', function ($scope) {
$scope.carpetList = 
      "Carpet": {
          "name": "red carpet",
          "standard": true,

Read the entire recipe Recipe added 8 hours, 42 minutes ago

$setPristine() not working.

**** Note I cut out some of my other functions so that the code could be read through faster. I cannot clear the form. when i click the button with the cancel function. I thought I could set a default form, but this doesn't make a difference.


Read the entire recipe Recipe added 9 hours, 39 minutes ago

Word wrapping in ng-grid header cells

I have a question regarding word-wrapping in ng-grid's header cells. I have tried adding

word-wrap: break-word !important; 

to a custom header cell template (as a style attribute on the ngCellText div), in the css for both the cellClass and...

Read the entire recipe Recipe added 10 hours, 41 minutes ago

tooltip-html-unsafe stopped working

I have a tooltip that displays an img - so I used tooltip-html-unsafe When upgrading to Angular 1.3 (or maybe earlier) it stopped working

  1. When trying to upgrade to 0.12 (I have 0.10) I get:
    angular#>=1 <1.3.0 which resolved to 1.2.27 and is required...

Read the entire recipe Recipe added 11 hours, 43 minutes ago

How to bind multiple JSON files in ng-repeat (AngularJS)?

I have multiple JSON files:


  "MainRegister": [
      "name": "Name1",
      "url": "url1.json",
      "name": "Name2",
      "url": "url2.json",


  "SubInformation": {

Read the entire recipe Recipe added 12 hours, 40 minutes ago

ionic responsive col for list item

Try to resize:

  <ul class="list">
    <a class="item" ng-repeat="thread in data" ng-href="{{thread.url}}" target="_blank">
      <li class="">

Read the entire recipe Recipe added 13 hours, 43 minutes ago

Form is undefined in scope in Angular 1.3

I don't if this is something I did, but once I upgraded to Angular 1.3, the form is no longer defined in my scope. My HTML is

<div some-dir>

    <form name="myForm">
    <!-- Form stuff here -->
    <button ng-click="submit();">

Read the entire recipe Recipe added 14 hours, 39 minutes ago

Angular-Material - Bug with Themes

I have recently stumbled upon Angular-Material. However It seems like the theme files are not being automatically included by the base angular-material.css file.

Therefor I must manually include every color theme that I would like to use...


Read the entire recipe Recipe added 15 hours, 35 minutes ago

Nested objects and ng-models in Angular-JS

I am looking for solution for a problem which might not exist the way I am trying to do it. So if anyone can help me with the best way of doing this.


I have the following input field:

 <input type="text" placeholder="quote"...

Read the entire recipe Recipe added 16 hours, 40 minutes ago

Angular Ctrl click?

How can I catch when user press Ctrl click ?

I can do it for single click using:

<input ng-click="some_function()"/>

but I need something like:

<input ng-CTRL-click="some_nice_function()"/>

Is that possible?

Read the entire recipe Recipe added 17 hours, 38 minutes ago

javascript does&#39;t convert angular ui datepicker date to UTC correctly

I'm using angular ui datepicker in my project( web api + angularjs). All works fine but when I'm trying to save date to Db it doesn't convert it to UTC format correctly and substructs 1 day(actually a few hours but it affects for a day too)....

Read the entire recipe Recipe added 18 hours, 37 minutes ago

Angularjs ui-router abstract state with resolve

Is it possible to make an abstract state with ui-router that needs to resolve data? I need to load the top half of a page with profile info, and then have a sub-nav that loads other details at the bottom of the page. The idea is that the abstract...

Read the entire recipe Recipe added 19 hours, 39 minutes ago

Saving the content of data into csv - AngularJS

Hi I'm trying to save the content of data which came from my webserver into csv file.

I'm trying this code which came from various question here in stackoverflow.

.success(function(data, status, headers, config) {

Read the entire recipe Recipe added 20 hours, 41 minutes ago

push if not exist in array object

I have the below model in JS . I am using angular js

$ = {
            FocusOn: " ",
            Filters: [],
            Range: {
                From: "",
                To: ""

I have the below function...

Read the entire recipe Recipe added 21 hours, 41 minutes ago

Error $window.height is not a function - ngInfiniteScroll with angularjs

I'm trying to load data dynamically with ngInfiniteScroll and I'm having a problem where I'm getting $window.height is not a function.

Here's a fiddle, it's not quite working and I'm not sure why, the data doesn't display on the fiddle yet it does on...

Read the entire recipe Recipe added 22 hours, 38 minutes ago

How to convert Blob to File in JavaScript

I need to upload an image to NodeJS server to some directory. I am using connect-busboy node module for that.

I had the dataURL of the image that I converted to blob using the following code:

dataURLToBlob: function(dataURL) {
    var BASE64_MARKER...

Read the entire recipe Recipe added 23 hours, 39 minutes ago

AngularJS Inject factory into another factory from the same module

I'm trying to inject the factory Application into the ApplicationService factory. Both are defined in the same module.

Application factory (application.model.js)

(function(Object, coreModule) {
    'use strict';       

    // the factory to expose...

Read the entire recipe Recipe added 1 day ago