Latest Angular.js Recipes

ngInfiniteScroll - loadMore() method gets called on every mouse-scroll

Solution below on the comments.

Problem: My loadMore() method gets executed on every container's scroll.

Meaning: loadMore() gets executed on each mouse scroll of the parent container (infinite-scroll-parent="true")

Desired result: to get...

Read the entire recipe Recipe added 33 minutes ago

Running Protractor Test receive error "ReferenceError: modules is not defined"

I'm trying to setup Protractor tests on a Windows machine. I have the server up and running but when I runt the tests, it fails and I get the following error: ReferenceError: modules is not defined"

I'm using the PageObject Pattern to structure my...

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

AngularJS : Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource

here is my code :

angular.module('option')
    .factory('optionListService', ['$resource', function($resource) {
    return $resource(HOST+'option/action/:id', {}, {
        'get':    {method:'GET'},
            'save':   {method:'POST'},
           ...

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

How do I test a .run in AngularJS?

myApp.run([
  '$rootScope', 'userService', function($rootScope, userService) {
    return userService.isAuthenticated().then(function(response) {
      if (response.data.authenticated) {
        return $rootScope.$broadcast('login', response.data);
  ...

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

ng-action does not add action attribute in the form

I want to have dynamic action attribute in the form. I have a code

 <form ng-action="/users/{{user.id}}">
 </form>

Angular does replaces {{user.id}} with the actual value, but it does not add action attribute with the new value. How do i fix...

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

How to list all languages that are loaded by angular-translate

I can't find it in docs or api of angular-translate. How can I retrieve all loaded languages by angular translate?

Assuming I have a LanguageCtrl like this:

angular.module('myApp')
.controller('LanguageCtrl', ['$translate', '$scope',
    function...

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

Codeigniter + Angular Js: How to receive JSON data

This is the situation:

I have a simple app made in Angular JS that comunicate with the server through an API made in codeigniter.

There is a login system in the app. When the user enter email and password, this data are sent to the server, if the...

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

Can I use Angular variables as the source of an audio tag?

I am trying to do the following:

<div ng-repeat="audio in event.audios">
    <audio ng-src="/data/media/{{audio}}" controls></audio>
</div>

But when I load the view, the {{audio}} variable is not parsed but hardcoded into the source as is. However,...

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

Angular UI-Router $urlRouterProvider .when not working *anymore*

Question: Why won't the .when() in my $urlRouterProvider work anymore?

I've picked up a fairly robust angular app. The most recent issue I've been trying to fix with it has been the 'user credentials lost on page refresh' issue.

The project's...

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

Show loading spinner while changing page in an Angular JS website

How can I show the loading spinner while loading the "next page" in an Angular JS webisite? Here's the JS code:

var app = angular.module('changePage', [])

app.config(['$routeProvider', function ($routeProvide) {
    $routeProvide
        .when('/',...

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

How can I compare two values in angularjs in HTMl

How can I compare two scope values using angularjs in HTML only?

for example:

<div ng-if="place.id = place.reference.id"> show if equals</div>

I want this to cover certain scanrios

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

UI-router interfers with $httpbackend unit test, angular js

This is a controller with a submit function:

$scope.submit = function(){   

 $http.post('/api/project', $scope.project)
      .success(function(data, status){
        $modalInstance.dismiss(true);
      })
      .error(function(data){
       ...

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

How to set the id attribute of a HTML element dynamically with angular js?

Provided an HTML element of type div, how to set the value of its id attribute, which is the concatenation of a scope variable and a string ?

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

error Duplicate data property in object literal not allowed in strict mode

i want to do multiple filter on angularjs using lb-services like this

  MasterTrip.find({ 'filter[include]':'froms',
                      'filter[include]':'tos',
                      'filter[include]':'trips'},function(respon){
     ...

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

How do I tell ui-Bootstrap what content to paginate?

I am using ui-Bootstrap and I am trying to get the pagination working but I seem to be missing something. I have read the documentation and looked at a bunch of plunkers to try and work out how they are specifying which content to paginate but I am...

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

Data Table with Angularjs

I am using angularjs with MVC5 (.net) for creating single page website. I have problem to bind data with "data table(jquery)"

When first time bind data in to table at that time it's work fine but when i edit the record and rebind the data with data...

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

File upload in ExpressJS and AngularJS using the REST API

I am new to AngularJS and Node.js.

I want to implement file (.pdf, .jpg, .doc) upload functionality using the REST API, AngularJS and Express.js.

I have tried to get an idea from Use NodeJS to upload file in an API call but I am still not clear how...

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

Makes Angular JS works offline

I am developing a single page application, with help of AngularJS and I'm new to it I asked the same question before but haven't got any answer so I am rephrasing my question and ask it again

THE QUESTION: What I need to do is to make my web app...

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

How to detect pressed keys on the click of AngularJS

I'm using angularjs on a webapplication that i need to figure out how can i detect is keys like ctrl, shift or alt are pressed when i click some where.

for example, with jquery i can do that by accessing the Click function arguments.

Is there some...

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

Text color picker in angular text editor directive

I would like to use textAngular directive, but I also need text color changing functionality, which as far as I know, is missing.

Is it really missing, or it's just an hidden option that i didn't find?

Thanks for your answers.

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

Call angularjs function using jquery/javascript

I am trying to call angular function using javascript/jQuery, following are the link I found

I have taken the same steps but getting error in browser...

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

ng-click doesn&#39;t work on anchor element

Q1: I tried to use nav in bootstrap to make a navigation bar and bound ng-click to the anchors. However after I click the anchor link,there is nothing happened.

Q2: I've noticed that the anchor link clicked won't be active by setting bg-color to it?...

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

Rendering a Star Rating System using angularjs

My app is in this Fiddle I need to render a star rating system dynamically from a http service, where the current stars and maximum stars can vary with each case.

Is it a good idea to create arrays from $scope.current and $scope.max - $scope.current...

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

karma declaration exception

I can't seem to get started with karma. While it's trying to load the service it fails. Here's the spec file:

describe('Service: angelloModel', function () {

    beforeEach(module('Angello'));

    var modelService;

    beforeEach(inject(function...

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

AngularJS select creates option with value &quot;? object:null ?&quot; and doesn&#39;t use empty default option when bound to null

Here's what the code looks like

<select ng-model="nullableInt">
  <option></option>
  <option value="0">First option</option>
  <option value="1">First option</option>
  <option value="2">First option</option>
</select>

When nullableInt is null the...

Read the entire recipe Recipe added 1 day ago