Latest Angular.js Recipes

Angular UI Router Nested State resolve in child states

In an angular app I'm working on, I'd like there to be an abstract parent state which must resolve certain dependencies for all of its children's states. Specifically, I'd like all states requiring an authenticated user to inherit that dependency from...

Read the entire recipe Recipe added 26 minutes ago

angularJS element.on callback and scope.$apply

In this example, I have an input with an attached directive. The directive is meant to display messages next to the input. There's another input and a button to add messages. Once some messages are displayed, focusing on the input with the attached...

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

How do I add multiple conditions to "ng-disabled"?

I need to check that two conditions are both true before enabling a button:

Here is an example:

<button type="submit" ng-disabled="frmUser.pw2.$error.pwMatch" class="btn btn-primary" ng-click="ChangePassword()">Change</button>

This example only...

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

Can you resolve an angularjs promise before you return it?

I am trying to write a function that returns a promise. But there are times when the information requested is available immediately. I want to wrap it in a promise so that the consumer doesn't need to make a decision.

function getSomething(id) {

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

Adding Cookies in Protractor for testing AngularJS

I'm having trouble doing a very simple adding & getting cookie test in Protractor for Angularjs. This is the test block:

describe("Homepage", function () {
    var ptor;

    beforeEach(function () {
        ptor = protractor.getInstance();

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

Form action with variable not valid after update to 1.2

I was generating a form action in my previous version of AngularJS using this code:

<form action="{{ api }}/products/image">

However, I just updated and now that apparently is too loose.

Error while interpolating: {{ api }}/products/image ...

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

angular-translate, issue with static loader (file loader)

I'm working with angular-tranlate.

I got it working with the $translateProvider.translations('en', en_translations); where en_translations is the json with the mapping.

Now I'm having a problem when trying to use static files:


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

How do you take a screenshot of an angularjs app?

I've tried:

  • node-webshot
  • phantomjs

I could do it locally but I couldn't take screenshots of other websites that are based on angularjs.


Be able to take a screenshot of any angularjs app which includes jquery and angular on the page....

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

Can the Angular $injector be decorated with $provide.decorator?

Perhaps this is a terrible idea, but if it is then please tell me why and then pretend that it's an academic exercise that won't see the light of day in production.

I'd like to add some logic to the Angular $injector service, to monitor when certain...

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

Angular how to filter by greater than on ng-click?

I need to filter the rows in witch the property "age" is greater than "x" number

    <a href="#" ng-click="personFilter = {age:18}">Older than 18</a>

<div ng-repeat="person in persons | filter:personFilter ">

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

correct way to initialise scope values when the view is loaded with angularjs, ngInit?

I've been learning angularJs for the past few weeks and been looking at a number of large scale apps to see how things work in the real world. In most of them I have noticed when a view is loaded :


i.e. the function init() is...

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

Passing parameters to modal dialog

I'm trying to use a simple modal dialog for editing an item in a list in the context of an Angular app. For modals I'm using UI-Bootstrap (AngularUI), which I know has still issues with Bootstrap 3 but AFAIK can be used for modals with some simple...

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

How to load AngularJS content via jQueryUI AJAX?

Our teams have inherited a jQuery Mobile project from another office and now we are trying to implement new features using AngularJS. The idea is also to migrate the whole jQuery website to AngularJS, step by step. Ideally, we would star the project...

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

Prevent AngularJS from dirty checking several thousand rows each $digest cycle

I have a data source that could potentially be several thousand rows. I want users to be able to scroll through the list and filter it without performance problems. My data source automatically fires an event whenever a record changes.

Currently this...

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

ng-show does not work with custom directive

I've just started using AngularJS and wanted to create a custom template directive for creating "in-place" editable tables. The idea would be to have something like:

    <tr ng-repeat="customer in model.customers">

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

Correct use for angular-translate in controllers

I'm using angular-translate for i18n in an AngularJS application.

For every application view, there is a dedicated controller. In the controllers below, I set the value to be shown as the page title.



<h1>{{ pageTitle...

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

Validation failing in IE9 using angular js

I am pretty new to Angular JS .Here I have a simple form as below: test3.php:

<!DOCTYPE html>
<html ng-app>
    <script src=""></script> 
    <form name="myForm" id="myForm"...

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

AngularJs + php authentication

Hi i started learning AngularJs and now im trying to do my Login module using angular and php, but i have some issues. I have watched alot tutorials but none of them was helpful in my case, so here is what i have: controllers.js:

var controllers =...

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

Angular 5 star rating bar

I want to show 5 star rating bar using angular and currently my code work only for integers with full star. But i want to use half stars for decimal values. how can i change this code. I can't use IF in my angular version.

<li ng-repeat="Star in...

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

Page Objects in AngularJS Protractor E2E Testing

What is the right way to handle the Page Objects model for writing Protractor E2E testing for AngularJS? I feel like I should write them in separate files (like homepage.js, page2.js, etc) then include somehow them into the specs like modules as need....

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

Blob url in internet explorer with angularjs

Given this code (from someone else):

var module = angular.module('myApp', []);

module.controller('MyCtrl', function ($scope){
    $scope.json = JSON.stringify({a:1, b:2});

module.directive('myDownload', function ($compile) {
    return {

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

single page application with angularjs and facebook share button

I follow this post to deploy facebook share botton in my app

The first problem is I can not pass, post.caption to facebook script.

The second one...

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

Pure Local Single-Page App With AngularJS and its RouteProvider

I'm currently trying to build a "web app" that runs off a flash drive, thus there can't be any other environment requires that launching chrome with some launch options and a path to the index.html file on the flash drive.

I'm having some trouble...

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

Manage files uploaded as a base64 string

I am currently developing a website with AngularJS for the frontend, and a restful web service using Laravel framework (PHP5) as backend ; I am currently face to one problem, file uploading. I would like to have a very simple file uploaded, with a...

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

AngularJS 1.2 ng-show height animation

I'm trying to get a height animation working using Angular JS 1.2. I've got a plunker here that has the animation working for closing the item:

With the key bit being this CSS...

Read the entire recipe Recipe added 1 day ago