Latest Angular.js Recipes

Cannot see the Restangular response data set in my chrome developer tools... is it bc my JSON contains nested JSON?

I'm currently trying to get a basic RESTful service up that pulls my JSON objects from MongoLab rather than the file-based implementation which I had working in my sandbox. Each of my JSON objects contain a child array (their predecessor...

Read the entire recipe Recipe added 44 minutes ago

How do I get dynamic content in an AngularJS Accordion body

I can see how to get static content in an accordion body, but can't figure out how to generate dynamic content.

Taking the example at the accordion is generated from ...

$scope.groups = [

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

How to load a different layout in angularjs

I have 2 layout files. Layout-1 Layout-2

The route /one is the starting point which loads the Layout-1, but now if I click on a link /two it gets me the file, but with Layout-1, instead i want, if i hit /two, Layout-2 should be loaded.

If i refresh...

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

Testing an angularjs directive which manipulates the DOM

I'm a complete beginner to Karma, so forgive me if it's a stupid question.

I'm testing a dirctive of mine, which is peculiar two ways:

1 - It conditionally changes template based on the scope content and recompiles the directive element inside the...

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

Creating tabs in AngularJs

I'm trying to create simple tabs using only divs with ng-show and ng-hide. I don't want to use jQuery or BootStrap. I have created the tabs but I cannot handle the divs correctly.

JS Fiddle

<div  ng-app ng-controller="sample">

    <div class="cb"...

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

Angular: update in factory model does not reflect in controller

I have a user preference factory that holds user preference values. When the page loads it is empty. After user logs in it is filled up with user profile. pseudo code

app.factory('pref', function($rootScope){
    var pref = {}, age, name;        

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

Using Promises in AngularJS Views

Mark Dalgleish wrote a nice little article about how to use promises in AngularJS views. Some people asked questions about this in the comments, but Mark didn't answer them (yet). Because I'm asking me the same question, I will ask on StackOverflow...

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

How to refresh ng-grid when griddata has different number of columns from previous displayed griddata

I do have an application where user selects an option to get grid data from server side and depend upon what option user selects, the number of columns in grid data may vary. I am using Angularjs and ng-grid to display data. The first time, it works...

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

How to hide a tag with ng-hide when the tag is empty (contains no text)

I want to hide every tag which has no content (simple text) using ng-hide directive. Here's what I am trying to accomplish:

<div class="menu-head" ng-hide="c1.section == ''">{{c1.section}}</div>

But this doesn't work. However, the following two...

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

Razor templates, views and angular.js


What are the best practices when using .NET Razor views and AngularJS?


We are developing a public website (not an intranet application) using mvc4 with razor, and we weren't very familiar with client script, so we started with what we...

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

Resolve on Angular UI Router appStates not Delivering Scope Data

I need data in a "sub" state and I am pulling my hair out trying to get it. The problem is I want the data to come from the $rootScope every time.

So here goes - an outline of my problem.

I'm using state provider. So here is my first state:


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

How to set $httpProvider default headers from my app config in AngularJS?

I'm trying to set my

$httpProvider.defaults.headers.common['X-CSRF-Token'] = $cookie.auth_token; 

in my .config section of my app, but it doesn't seem like I can access the document/cookies just yet? Is there a better place to set this?

I'm doing...

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

FACTORY: get current for Firebase Simple Login (Email / Password)

I am looking for a solid way to have the 'current user id' in all my controllers available. Using: Firebase Simple Login : Email / Password Authentication

My ida: I need a 'Factory' wich I can inject into my controllers, to have the 'current user...

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

Single Page Application SEO and infinite scroll AngularJS

We are have a site with a feed similar to pinterest and are planning to refactor the jquery soup into something more structured. The two most likely candidates are AngularJS and Backbone+Marionette. The site is user-generated and is mostly...

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

In angular, what does an ampersand in the directive mean?

In this code:

app.directive( 'myCustomDirective', function() {
  return {
    restrict: 'EA',
    scope: { value: '=myCustomDirective', clickable: '&', editing: '=' },
    template: '<span ng-click="handleClick()" ng-bind="value"></span>',

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

submit form using link tag with angularjs

I'm still new with angularJS. I've been trying to make a custom button and attach it to my form instead of using regular button. I've tried couple of approaches and so far none of them worked well. now when I press enter inside the input field I get...

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

How to access AngularJS variable from template script

My controller:

$scope.totals = totals;

My template (works as expected for html injection):


But what I need is to access the variable totals in a script in the template, like so:

  var totals = ????;
  // do stuff with...

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

Ng-animate not working in AngularJS?

I'm working on a mobile app using Phonegap and AngularJS. I'm currently just developing and testing on a local wampserver for ease.

I'm trying to get ng-animate working on my ng-view, in order to animate changing of views similar to mobile apps. Any...

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

Angularjs auto refresh momentjs fromnow date value

I am a new to UI development and i have to develop a page which has a number of posts with creation dates. The creation date is displayed relative to current time like '3 hours from now'

I refereed this link and was able to do that successfully. But...

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

How to return/edit REST resource with AngularJS &amp; Restangular

Using Restangular for AngularJS, keep getting an object object from Mongolab.

I'm sure it has to do with Promise but not sure how to use/implement this coming from old Java OO experience.

(Side note, would something like Eloquent Javascript, some...

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

File download links with angulars UI-Router

I'm trying to create a simple link in my angularJS app to files that have been uploaded. I have no problem producing the link, as this is pretty trivial. The issue I have however, is that the routing system I have intercepts the link and tries to load...

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

Get selected item with ng-options

I have an array with attributes and I'm trying to select a certain one on load.

Each of my attributes have attribute object, type object and an array of attributeValues.

I want to select the attribute value with chosen=true

Here's my Angular...

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

angularjs ng-style: background-image isn&#39;t working

I'm trying to apply a background image to a div by using the angular ng-style ( I tried a custom directive before with the same behaviour ), but it doesn't seem to be working.

    data-ng-class="{ bigger:...

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

inline CKEditor + AngularJS + dataprocessing

I'm trying to use CKEditor with AngularJS for WYSIWYG editor with data-binding and everything seems to be working well. Extreme configurability helped a lot with our requirement matching.

We are now facing an issue with dirty form.



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

AngularJS: html special characters are not showing

I'm trying to display a string in my model that contains the html representation of a special character. Unfortunately, it doesn't show that actual character, and I don't know how to make it do it...

this is the code:

<div ng-controller="MyCtrl">

Read the entire recipe Recipe added 1 day ago