Latest Angular.js Recipes

How to get the intellisense in visual studio 2012 for AngularJS

How can i get the intellisense in visual studio 2012 for angularjs in Html. I search these through many websites but it's not working ... please help

Read the entire recipe Recipe added 14 minutes ago

How can I get the width of an element using AngularJS?

I realise I can use jQuery to get the width of an element, but I'm curious; is there a way to do so using AngularJS?

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

Toggle button is not working with AngularJS and Angular ui Bootsrap

The toggle button appears but it is not working. I've got a same code now in online as well and it is not working but in Plunker it is working.

Plunker - toggle button is working

Same code online - button is not working

And the code is:

<div...

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

AngularJS SPA and RestfulAPI Server Security

Quick background:

Full Javascript SPA AngularJS client that talks to a REstful API server. I am trying to work out the best authentication for the API Server. The client will have roles and I am not concerned if the user can see areas of the client...

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

Changing ng-view animation class dynamically with Angular

I am trying to toggle between two animation classes within my ng-view. This is how I have my ng-view setup in my html:

 <div id="animation-container" class="view-animate-container">
    <div id="ng-view" ng-view class="view-animate"></div>
 ...

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

How to reset angular filter property

I have a list of filtered data:

<tr ng-repeat="course in courses | filter:search:true">
    <td>
        <div>{{course.course_name}}</div>
    </td>
</tr>

and a SELECT input to help filter it:

<select ng-model="search.location_id">
    <option...

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

Error: [$injector:modulerr]

I am a newbie. Just learning/trying to integrate Angular with my webapp (Java + jQuery+ requireJS). I am not using any router and below is my script. From other stackoverflow I learned that this error is due to missing inclusion of ngRoute module....

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

What is the point of the underscores in Angular JS testing dependency injection

I am currently working on a tutorial that integrates angular JS into a Rails app.

Tests are setup as follows:

describe( 'Club functionality', function() {
  // mock Application to allow us to inject our own dependencies
 ...

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

Conditional binding with AngularJS, concatenate and bind value if property is not empty

I am new to Angular and am trying to bind a string to a model if the value !== empty. This work for one input, but I would like to combine multiple text inputs into one string.

<input type="text" ng-model="data.source">
<input type="text"...

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

Angular - abort ajax request when using Restangular

I have a method that calls an angular service and consequently makes an ajax request via the service. I need to make sure that if this is called several times, the previous request in aborted (if it hasn't already been resolved that is).

This method...

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

Ng-repeat, first item with different directive

I got the following code:

<div ng-repeat="i in placeholders" square class="set-holder {{i.class}}" droppable="{{i.type}}"></div>

How I make the first item has the directive bigsquare, while the others have just square.

I've tried:

<div...

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

ng-style not working inside nested ng-repeat

I've got the following markup:

              <li ng-repeat="month in months">
              <!-- NOTE THAT THIS IS WORKING IN ALL BROWSERS -->
                <div class="cm-month-grid" ng-style="{width:{{month.pos.width}}+'px',...

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

Showing unique dropdown options in Angularjs

I have a following drop down which is working fine

                     <select class="form-control" ng-model="cc.id">
                       <option value="">Chose Id</option>
                       <option ng-repeat="account in accounts...

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

How to show a message when filter returns nothing in ng-repeat - AngularJS

I would like to show one div(message) when no items returned on filter(ng-repeat).

Filter is happening based on select box (ng-model). And there are no results for some select options, at that time user should be able to read a message at same...

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

How can I find the index of an object inside a Array using underscore.js?

I want to get the index of the given value inside a Array using underscore.js.

Here is my case

var array = [{'id': 1, 'name': 'xxx'},
             {'id': 2, 'name': 'yyy'},
             {'id': 3, 'name': 'zzz'}];

var searchValue = {'id': 1, 'name':...

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

AngularJS: Call a particular function before any partial page controllers

I want to call a particular function: GetSession() at the beginning of my application load. This function makes a $http call and get a session token: GlobalSessionToken from the server. This session token is then used in other controllers logic and...

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

Angular function filter comparator example

Can someone give me an example of how to use Angular filter comparator?

From official doc:

function(actual, expected): The function will be given the object value and the predicate value to compare and should return true if the item should be...

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

AngularJS: open a new browser window, yet still retain scope and controller, and services

I'm writing an angularJS app. In this particular controller, I open a new browser window through the $window.open service. But in the new window, all the $scope variables are lost.

I tried to use window.parent but this doesn't work. In fact in the...

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

How can I have Angular-Translate preload my translation before I can use it inside my controller?

I am trying out Angular Translate and I need to use the translations inside my controller, but the controller runs the code before my translation is even loaded yet..here is my code:

var myApp = angular.module('myApp',...

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

How can I parse external link url using native angular code?

everyone. Sometimes I need some way to get some part of external site url in my angular code. But there's obviously no way to do it with native angular services, and I don't wanna use some Jquery library for parsing url. I need some service for url...

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

AngularJS transformResponse

In angularjs resource, I would like to convert my json data into JS objects

//Complex object with inheritance chain
function Car(year, make){
    this.make = make;
    this.year = year;
}


var carResource = $resource("/api/car/id", {id: '@id'},
   ...

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

AngularJS: change json object values with input fields (with ng-click for instance)

"myData" in the code below is a json object which I extract from $http.get response (I call the request when my web app is initialised). User has to be able to change the data, so I created the code below with inputs that are filled with values in...

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

Angular JS not loading view

I'm trying to get my first AngualarJS app going but it won't work for some reason. Been googling for a while now and haven't found a solution that works for me yet. Can anyone with some AngularJS exp see what's wrong with my code? Appreciate any...

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

Angular js - show/hide loading gif every new route

I'm trying to toggle (hide/show) a loading gif on every new route, so my logic would be:

  • routeChangeStart = show loading gif
  • routeChangeSuccess = hide loading gif

This is my code:

//ANGULAR
app.run(function($rootScope) {

   $rootScope.layout...

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

bound element inside ngIf does not update binding

I have written a angularjs directive. in this directive's template I have added an ngIf directive and within it I display an input that is bound to my directive's scope.

<div ng-if="bool"><input ng-model="foo"></div>

I noticed, after a lot of trial...

Read the entire recipe Recipe added 1 day ago