Latest Angular.js Recipes

Can I inject JointJS as an AngularJS module like any other library?

I have an app with angular and I need to use this library http://www.jointjs.com/, So I downloaded the joint.min.js and joint.min.css and placed their routes in the index.html but I don't know what to put in the app.js to inject it and I keep getting...

Read the entire recipe Recipe added 17 minutes ago

Browser compatibility of angular.js and angular-ui bootstrap

I trying to decide whether I could to use angular.js (and anguar-ui-bootstrap) in my project.

The web application should work with any reasonably modern browser, I was quite surprised that the right on the angular-ui-bootstrap site, after clicking on...

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

How To use Php session variable as Angular Js Data

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

app.controller('TodoCtrl', function($scope){

  $scope.todos = ['test'];

  $scope.done = function(todo){
          var indexOf = $scope.todos.indexOf(todo);
          if (indexOf !== -1) {
             ...

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

AngularJS dropdown not showing selected value

Am facing problem in displaying selected value in angular dropdown. it works when i give like this

$scope.selectedItem = $scope.items[1];

not working, if i give directly that value

$scope.selectedItem = { name: 'two', age: 27 };

HTML:

<html...

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

Can I access parameters in my protractor configuration file?

I start my protractor tests by running the following:

protractor protractor.conf.js --params.baseUrl=http://www.google.com --suite all

I would like to run a 'before launch' function which is dependant of one parameter (in this case, the baseUrl)....

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

Fixing AngularJS error: Provider must return value from $get factory method

When I use the code below, I am getting the following error:

Provider 'Login' must return a value from $get factory method.

I've reviewed the stackoverflow posts here and here, but can't figure out what I'm doing wrong.

myApp.factory('Login',...

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

Chart.js not showing in my view

I have an app running with angular.js and one of my view should load an chart. I'm using chart.js for it, but for some reason it's not working and no error is shown on my console. Here is my function that creates the chart:

$scope.writeBatteryChart...

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

values not showing up in select button

I am trying to get options in select button but its not showing up.

my code is as below:

index.html:

<select ng-model="main.order" ng-options="order as order.title for order in...

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

Iterate over array when forEach loop is all done

Im trying to iterate over an array that I construct from multiple http calls inside a angular.forEach()

the function

$scope.ticket_stats = function(){
    //cleaning variables
    $scope.data_set = [];
    $scope.closed_tickets = [];

    //fetching...

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

how can I get the current url using protractor?

I am testing a website using protractor, and jasmine. I would like to know the current url in order to verify a test.

I have tried

function waitForUrlToChangeTo(urlRegex) {
    var currentUrl;

    return browser.getCurrentUrl().then(function...

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

How to do dropdown item on navbar with material angular

I'm using Angularjs with googles Material Angular library https://material.angularjs.org/

They have drop down items in the navbar on their site, but I can't find any object or example to make one of my own.

How can I achieve this?

Thank you!

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

$rootScope is not defined

I'm trying to use a cookie value in multiple places and within multiple controllers but I get error saying $rootScope is not defined

Here's the code:

capApp.controller('cookieCtrl', ['$scope','$cookies', function($scope, $rootScope, $cookies) {
  //...

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

Angular Ui-Grid display List view on row expansion not a Subgrid and pass the selected row id and data

I am trying to display a list view on row expansion of the ui-grid instead of a sub-grid Example when the User clicks on the expansion icon of the row, instead of displaying a subgrid i want to display a list view, I am able to get to a point where I...

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

Angular JS Action on ng-change the select dropdown

I have a simple table with three rows and two values for each row - date and state:

<tbody>
   <tr>
      <td>Red</td>
        <td class="lastModified">{{item.redDate}}</td>
        <td class="status"> 
            <select id ="red"...

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

How to target ng-show on specific items in ng-repeat?

http://plnkr.co/edit/aiGCPJEwTj0RWnuoCjsW?p=preview

I want the remove button to only show the popover for that item.

How would you go about this? HTML:

<li ng-repeat="acc in accounts">
    <div class="well well-sm">
        <div...

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

Chart.js in AngularJS tabset does not render

I am using a AngularJS module based on Chart.js to display graph. It works like a charm, but when I display a chart in a AngularJS tabset, the graph does not render if it is not the first tab.

  <tabset>
    <tab heading="Tab 1">
        <!-- OK -->
...

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

Expected response to contain an object but got an array for GET action

I'm getting this error "Error: [$resource:badcfg] Error in resource configuration for action 'get'. Expected response to contain an object but got an array"

and I don't know how to fix it. I have this...

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

ui-router with ControllerAs binding

ui-router State:

$stateProvider
    .state('dashboard', {
        url: '/dashboard',
        templateUrl: 'app/dashboard/dashboard.html',
        controller: 'DashboardController as vm'
    });

In DashboardController I have:

var vm =...

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

How to pass array parameter to AngularJS $resource

When I pass an array to a resource action.. it doesn't convert the array parameter to an array of URL parameters

var Product = $resource('path/products');
Product.query({ids: [1,2,3]})

Instead of getting:

path/products?ids[]=1&ids[]=2ids[]=3

I'm...

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

How to check a checkbox while doing protractor e2e using AngularJS

I'm currently doing a testcase for a program, and I need to check the checkbox in the e2e test.

Being new to e2e, I don't have a successful idea on how to do it for checkboxes

Any help or links appreciated.

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

AngularJs Disable Submit Button Until A File Upload Path Selected

I'm new to AngularJS and I can seem to find a solution to my problem. I have a file upload field on my site and a submit button. This page has a drop down list and a disabled submit button when the user first hits the page. The submit button is...

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

AngularJS: &#39;$scope is not defined&#39;

I keep getting '$scope is not defined' console errors for this controller code in AngularJS:

angular.module('articles').controller('ArticlesController', ['$scope', '$routeParams', '$location', 'Authentication', 'Articles',
        function($scope,...

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

Protractor - How to upload file using ng-file-upload in test case without changing code?

I am using https://github.com/danialfarid/ng-file-upload for file upload. I have to test it so I wrote protractor test case but it not working.

Code

<div class="col-lg-12 up-buttons">
     <div ng-file-select="" ng-model="files"...

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

How to navigate to different pages using ui-route with angularjs?

I have used tabs and routed pages with ui-router, now i have changed the layout and having buttons in the side navigation panel to route to different pages on button click. No idea how to go after trying so many examples.

I need to navigate to...

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

How serialize objects with angularjs

How can I serialize an object without using the $.param jquery?

I want the object below:

var user = {username: 'ronald.araujo', password: '123456',};

to have the following output:

username=ronald.araujo&password=123456

Any suggestions?...

Read the entire recipe Recipe added 1 day ago