Latest Angular.js Recipes

bootstrap angular datepicker set ng-model $invalid not change

I am Useing Bootstrap angular datepicker in a form to update my model 'User'.

I set this datepicker 'require' property is true. UpdateUser.html:

<form name="userForm" novalidate>
    <div class="form-group">
        <label>Birthday</label>
       ...

Read the entire recipe Recipe added 15 minutes ago

$http POST response from service to controller

How to get the response from Service in below case??

Service:

app.factory('ajaxService', function($http) {
    updateTodoDetail: function(postDetail){
        $http({
            method: "POST",
            headers: {'Content-Type':...

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

Passing data to a custom directive in AngularJS

I have a page that displays a bunch of thumbnails of images that are retrieved using http. I use ng-repeat to go through the array and generate the html.
This works fine.

I also create a custom directive that I tie as an attribute to img elements...

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

Chain promises with AngularJS

I have a service called paymentStrategy that get injected in my controller.

$scope.buy = function() {
  paymentStrategy.buy()
    .then(function(response) {

  }
}

This buy method from paymentStrategy triggers several methods that needs to be...

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

How to convert dash-case to camelCase in AngularJS?

Is there any utility function in AngularJS that converts a dash-case string to a camelCase string? e.g.: "min-max" becomes "minMax"

That's quite simple to implement my own function:

function toCamelCase(name) {
  return name.replace(/-(\w)/g,...

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

UI- Router -- run function on every route change -- where does the state name live?

Using Angularjs and UI-Router, trying to run a function every time state changes

$rootScope.$on('$stateChangeStart',
        function(toState){
            if(toState !== 'login')
            UsersService.redirect();
        })

I put this in .run()...

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

Angular JS - Date changes when submitting to $http - Timezone issue

I am having a strange problem where a Date changes when it is passed to API through $http.put, I suspect a timezone issue:

Datepicker triggers ng-change event - console.log:

Tue Jun 10 2014 00:00:00 GMT+0100 (GMT Summer Time)

Passed to API using...

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

Difference between $http.get , $http.post ,$http.put , $http.delete $http.head and $http.jsonp

I am new to angular js and web development. Please help me.

Today i read about $http in angular js but i am only aware about the get and post methods .

Can Please anyone explain ,me what is the Difference between $http.get , $http.post ,$http.put...

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

Angularjs ng-view not showing data

I am learning Angularjs from Tuts+ Easier JavaScript Apps with AngularJS tutorial. Now I am at the part where they discussed Routing Primer using ng-view. I am trying to show the list page contents in ng-view of index page. For some reason nothing is...

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

How to watch for change in one particular nested array item attribute in Angular JS?

I have an array that looks like this:

$rootScope.array = [{

                    "id":"a",
                    "title":"a",
                    "options":[
                                {
                                  "optId":"abc",
           ...

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

Save mongodb data from post form and angular

This is my jade file (basically # stand for id and . for class) and I want to send this to mongodb and save user.activity

textarea#post-form.form-control(
    rows="4",
    placeholder="Share to world of LinkMe",
   ...

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

AngularJS - Get $scope variable from string

So say I have a $scope variable defined like so:

$scope.data = {
    filter: {
        state: 'WA',
        country: 'US'
    }
};

How do I access that in a separate service by string? e.g. data.filter in the context of the $scope.

So say I have a...

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

Angular ui-router state is not loaded

Hi I have started to learn angular for a couple of days now and I gotta say it has been a bumpy road.I'm not new to SPA apps I have been working for the past year on a project that used Durandal.

In two days I will have to start working on a project...

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

Getting &quot;$digest already in progress&quot; in async test with Jasmine 2.0

I know that calling $digest or $apply manually during a digest cycle will cause a "$digest already in progress" error but I have no idea why I am getting it here.

This is a unit test for a service that wraps $http, the service is simple enough, it...

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

AngularJs : How to merge two or more scope into single scope

Actually am sending the data from registration form with multiple scopes ie (veh_register,noofpass,avilableData,foundedClass).......

Every scope object has data like veh_register :{ "vin" : vin89, "vplnum" :AR 890S, "uni" :proxu} ...

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

AngularJS call method inside $routeProvider

I'm newer in AngularJS. So I have a simple question, but I can't find answer. I have code:

angular.module('app', ['app.controllers', 'ngRoute']).
config(['$routeProvider', function ($routeProvider) {
    $routeProvider.when('/users', {templateUrl:...

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

XMPP: AngularJs + Strophe.js

I have a basic XMPP client working on strophe.js.

On login I create handlers such as

connect = new Strophe.Connection('http://localhost/http-bind');
...
...

    connect.addHandler(on_message, null, "message", "chat");
   ...

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

How to check if element with ID exists in AngularJS

How can I check if an element with a specific ID already exists in my DOM inside an Angular directive? By using angular.element() an element is created if one does not exist, for example angular.element('someID') will return an element whether one...

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

How to trigger ng-change from jquery?

I have a select tag as follows:

<select ng-change="doSomething()" ng-model="myModel"> </select>

and I'm using a jQueryUI control for it (combobox), the event "change" triggered from jQuery doesn't trigger doSomething().

Do you know how to trigger...

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

Laravel/Angular: passing data within php page to angularjs

I have the following laravel html/blade page and i want to pass in a storeid that then can get picked up via angular to then use to get and do some workings with.

Below is how i am accomplishing it NOW but is there a better way to produce the...

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

Failed to execute &#39;setRequestHeader&#39; on &#39;XMLHttpRequest&#39; [...] is not a valid HTTP header field value

I am developing an application with AngularJS (client side) and Java (server side) using RESTful services (with Jersey).

In the client I have something like this

$http({
        url : "/Something/rest/...",
        method : "POST",
        headers :...

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

Convert milli seconds into Date in DD/MM/YYYY format in angularjs

I have written a service which returns date in milliseconds , but I want to show it in format 'DD/MM/YYYY' , how can it be done?

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

$interval function continues when I change routes

I am getting a problem regarding an $interval function continues when I change routes.

This is the code:

  x = 2;

 var multiply = function () {
     x = x * 2;
     if (x == 134217728) {
         $interval.cancel($scope.stop);
         $scope.stop...

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

AngularJS Long Polling - push result to list

Currently I can push long polling results to the $scope.newMsg variable, however I would like to add it to the messages list $scope.messages.push(msg).

This is my current app.js:

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

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

What is the difference between createspy and createspyobj

I have used in my code like.

return $provide.decorator('aservice', function($delegate) {
            $delegate.addFn = jasmine.createSpy().andReturn(true);
            return $delegate;
        });

In that what createSpy do? can i change the...

Read the entire recipe Recipe added 1 day ago