Latest Angular.js Recipes

show validation error messages on submit in angularjs

I have a form which need to show validation error messages if clicked submit.

Here is a working plunker

 <form name="frmRegister" ng-submit="register();" novalidate>
        <input placeholder="First Name" name="first_name" type="text"...

Read the entire recipe Recipe added 25 minutes ago

Select multiple list items using angularjs

I'm trying to select a particular list item from elements in an unordered list. It should appear as selected, which I need to show by changing some background.

I was trying to use $index which comes as undefined as I was trying to use it within the...

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

AngularJS - Select value returns &quot;? number:x ?&quot; from scope variable

Trying to get the initial value for a select element and instead of populating the value, it adds a weird string as seen in this image:

enter image description here

Here is the JavaScript code:

 function appCtrl($scope){
        $scope.teams = [
            {teamId: 10,...

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

sails.js: how to update model

Forgive my noob question. I'm using angularjs to send a user model (json) with varying fields. It works well with sails.js default PUT. I overrode the PUT, the problem is that I wish to update the model with the received JSON and do some processing on...

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

AngularJS multiple filter with custom filter function

I am trying to filter the list with multiple filters + with a custom filter function.

The original working jsfiddle example is but now I want to change the way age are being filter.

I want to add a custom filter so that...

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

Scala PlayFramework and Angular JS - too much effort in terms of duplication and mixing concetps

I tried to write an application on playframework + scala + Angular JS. The purpose was to create an web app that would work either good when JavaScript is OFF or ON in the browser. This is usual requirement when one writes Public Site (which should be...

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

Render value without data-binding

In AngularJS, how can I render a value without 2-way data binding? One may want to do this for performance reasons, or even rendering a value at a given point in time.

The following examples both use data binding:



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

Sortable table columns with AngularJs

I'm trying to sort a table of data which is populated from a JSON source. The code I have is as follows:


<div ng-app="myApp">
    <div ng-controller="PurchasesCtrl">
        <table cellspacing="0">
            <tr class="first">

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

How can I directly inject $http into a provider?

All I need to do is to download a json file and assign it to OCategories in PCategory provider after I set the path. However I get an error that $http doesnt exist. How can I inject it into my provider and download inside of the setPath function?


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

AngularJS | handle routing before they load

I wish to create a simple authentication check for my routes by external service.

I define the access requirements on the route object:

    .when('/', {
        templateUrl: 'src/app/views/index.html',

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

Delete item from data-bound JSON list using AngularJs

I have a list of messages which are bound as an HTML list from a JSON source. There is a delete button next to each image. I'd like to remove a message from the list when the delete button next to that message is clicked.



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

Why do i have to call $scope.$digest() here?

I created a directive for showing tooltips:

        restrict: 'A',
        link: function(scope,element,attr){



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

Angular directive with default options

I'm just starting with angularjs, and am working on converting a few old JQuery plugins to Angular directives. I'd like to define a set of default options for my (element) directive, which can be overridden by specifying the option value in an...

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

Angularjs minify best practice

I'm reading and it turned out that angularjs dependency injection has problems if you minify your javascript so I'm wondering if instead of


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

Render 404 instead of redirecting 404 in angularjs

I'm looking for a good approach to render 404 page instead of redirecting 404 page in angularjs. Many solutions I have found is all about redirecting to another page. It will create a problem that if the user click on browser's back button I will...

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

How to debug Angular JavaScript Code

I am working on a proof of concept using Angular JavaScript.

How to debug the Angular JavaScript code in different browsers (Firefox and Chrome) ?

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

change attribute of target when click using angularJS

<ul class="todo-list">
    <li ng-repeat="todo in todos">{{todo.todoContent}}<span class="pull-right glyphicon glyphicon-check" ng-class="{checked:todo.done}" ng-click="todoCheck(todo)" title="check this todo">check</span></li>

Now I want...

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

How to reload a page using Angularjs?

I have a link. When user will click in this link, then the page will be reloaded. I did it by the following way......


<div data-ng-hide="backHide" class="offset6 pull-right">
     <a href="" data-ng-click="backLinkClick()"><< Back  <br/>...

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

AngularJS: Communication between directives

I'm writing a directive which creates an mp3/audio player. The issue is that you can have many audio players in one page. What I would like to do is when one is playing and you start an other, that the one currently playing pauses. How can I achieve...

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

using angularjs http-auth with $resource

I am trying to make HTTP Auth Interceptor Module work together with $resource.

for now, i have a basic app working with services like this :

angular.module('', ['ngResource']).
factory('User', function($resource){

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

npm install -g karma error MSB4019: The imported project &quot;C:\Microsoft.Cpp.Default.props&quot; was not found

I've been looking into AngularJS and following its install steps, but I get an error running step #1:

npm install -g karma

Here is the full output:

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights...

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

AngularJS directive loaded with RequireJS not compiling

I'm in the beginning stages of building a large app with AngularJS and RequireJS. Everything loads find but directives aren't manipulating the DOM as they should. No errors are being reported and rest of the app works fine: Views are loaded and $scope...

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

How to test endpoints protected by csrf in node.js/express

I have implemented csrf (cross-site request forgery) protection in an express like so:

app.use(function (req, res, next) {
  res.cookie('XSRF-TOKEN', req.csrfToken());

This works great. Angularjs...

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

Angular.js get index of last element in 2d array in ng-repeat

I have this 2d array in my controller:

1 2 6
1 2 7 9
1 5 3 2 6

I need to show to the user the last element of each row (example: 6, 9, 2, 6) I think I need to use some combination of directive ng-repeat or get the $last index of the array using...

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

angular how to disable validation on condition ng-required

I have a variable on the scope which I use to check for condition

$ = $resource().query(); //returns array always

So i have a regular validation with a ng-required directive

<input ng-required="{{data.length}}"/>

now when the data is...

Read the entire recipe Recipe added 1 day ago