Latest Angular.js Recipes

How to adjust toaster popup width

I'm using AngularJS-Toaster to popup notifications in my app. For the frontend I'm using bootstrap.

Using the class 'container' I have a grid of 1200px. Inside I have a div with the popup notifications.

I would like to adjust the width of the popup...

Read the entire recipe Recipe added 32 minutes ago

AngularJS ng-repeat to populate grid from array

Thanks in advance for reading. I am trying to utilize angular's ng-repeat to render objects from an array into an Nx3 Table. For the sake of example let's consider a 3x3 table.

Here is a simplified example of the array:

objects = [{"text": "One,...

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

How to test if event.target.hasClass() using angular and jqlite?

After a click pass the event to ctrl. I want to write a conditional that will return true if the element.target has the class modal-click-shield

Question:

How can I use .hasClass() with event.target using angulars' jqlite?

Problem:

Currently I'm...

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

Angular Material wont apply styles

I got a problem when I try to use Angular Material design. It wont style anything.

This is my HTML:

<!DOCTYPE html>
<html ng-app>
<head lang="en">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1,...

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

Promise factory in Angular

New to Angular, may be using promises wrong. I have a factory returning a promise:

.factory('myData', ['$http', '$q', function($http, $q) {
    var deferred = $q.defer();

    $http.get('/path/to/endpoint')
        .success(function(data) {
        ...

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

checkbox unchecked to make form invalid

trying to add form validators for the checkbox in my form, in case if it's unchecked the form will have ng-invalid.

<li class="terms_checkbox"><input type="checkbox" id="checkbox_terms" name="terms" /><label for="checkbox_terms"></label></li>
<li...

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

How to use a local JSON object with angular-datatables

I would like to do this :

testdata = [{"id":"58",...}]; // local object

$('#test').dataTable({
    "aaData": testdata,
    "aoColumns": [
        { "mDataProp": "id" }
    ] });

with the angular-datatables module. I have tried this :...

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

inserting iframe from trusted source in AngularJS

Trying to use ng-bind-html to insert iframe into page with AngularJS & I can't get it to work it on even the simplest form.

Javascript

function Ctrl($scope) {
   $scope.showIt = '<iframe src="http://www.anything.com"></iframe>';
}

My HTML:

<div...

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

How can I modify an AngularJS Bootstrap dropdown / select so that it does not use jQuery?

I saw a really good example of a AngularJS Bootstrap type of Select directive:

http://jsfiddle.net/cojahmetov/3DS49/

This meets most of my needs but it uses jQuery and we are not using that library.

The jQuery used in this example is very minimal...

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

AngularJS custom directive with input element, pass validator from outside

I'm using a simple custom directive for a modified input field which occurs throughout my application:

app.directive('editor', function() {
    return {
        restrict: 'E',
        templateUrl: 'editor.html',
        scope: { value: '=' }
   ...

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

How to select an element in protractor having multiple classes?

I have a div like this:

<div class="class1 class2 class3" ng-click="displayItems(category.categoryId, category.categoryDescription, category.associatedToElements, 'isItemChecked')"> </div>

When I am trying to get the element in Protractor by...

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

How get data from array in json item using angularjs

I have a little Issue.. My items have attributes and each attribute is used like key and value.

I need put value from attribute key desctiption in my page.. but i dont know how do it.

Here is my json data

[
{
    "id": 2323,
    "name": "small...

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

How to $state.go()

Is my $stateProvider:

$stateProvider
.state('home', {
    url : '/',
    templateUrl : '/admindesktop/templates/main/',
    controller : 'AdminDesktopMainController'
}).state('company', {
    url : '/company',
    templateUrl :...

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

AngularJS Smarttable - event on select

Is there a way to trigger an event on row select in AngularJS Smart Table?

This was a subject in other thread but still no answer to this point.

Unable to select the grid item using SmartTable in Angular JS

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

Uncaught Error: [$injector:modulerr] Failed to instantiate module error on Angular.js App on Apache

I'm using Apache server to host an angular app. This is the index.html:

<html>
  <head>
    <script src="/lib/angular/angular.js">
  </head>
  <script>
     myapp = angular.module('myapp', []);

     myapp.controller('indexCtrl', function($scope){

...

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

No injector found for element argument to getTestability

I'm trying to run this tutorial against my own AngularJS code. I can't get past the first test. Any attempt to pull any information from my page gets this error:

     Error: Error while waiting for Protractor to sync with the page: "[ng:test] no...

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

AngularJS: How to parse JSON string to integer or float to display it in form number field

I am using AngularJS for my front-end and Laravel for the back-end. I am passing a variable to front-end screen called orderItems which contains the following data to my front-end.

[{
    "item_description": "CAD Machine ",
    "qty": "1",
   ...

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

AngularJS : How to load an ng-click function of a radio button on loading of the page?

There are 2 radio buttons, offline and online:

<input type="radio" name="mode" ng-click="offlineFn()" >Offline
<input type="radio" name="mode" ng-click="onlineFn()">Online

ng-click of offline is ng-click="offlineFn()".

This fn should be called on...

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

The request was redirected to &#39;https://..com/site/login?&#39;, which is disallowed for cross-origin requests that require preflight

Before posting this question i have gone through most of the stack overflow questions but i didnt got an answer

i am trying access an client api which will do Oauth authentication so when i call the api it should thrown an popup window for...

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

Django REST Framework upload image: &quot;The submitted data was not a file&quot;

I am leaning how to upload file in Django, and here I encounter a should-be-trivial problem, with the error:

The submitted data was not a file. Check the encoding type on the form.

Below is the detail.


Note: I also looked at Django Rest...

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

smart table column show/hide toggle

I'm new to AngularJS and SmartTable...I'm currently trying to get SmartTable to have a show/hide toggle for the columns. From what I undertstand SmartTable doesn't do this, so I am using the ng-Grid show/hide feature...trying to follow this...

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

adding ng-invalid class on input mismatch

Angular adds ng-invalid class automatically to email input field if it's invalid, how's it possible to have the class ng-invalid added to input#confirmEmail if it's doesn't match to input#email and remove if they match.

Basically I'm not required to...

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

Protractor wait for isElementPresent and click on waited element fails

I have a issue with my end2end tests. Sometimes they pass without any problem but two thirds of the time they fail. I use protractor with following code:

 describe('Admin dashboard delete Exports', function () {
        it('create export', function...

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

How do I redirect after ajax request in angularjs?

I am using angularjs and nodejs for my project. Now after I do my authentication using background call. Now after I receive my successful authentication, how do I redirect the user to dashboard? Here is my login div:

  <div ng-controller="loginCtrl"...

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

Use element by css to check if element exists in Protractor

In a protractor end to end test, I want to check if an element exist using element(by.css(...)), my code:

var myElement = element(by.css('.elementClass'));
expect(myElement).toBeUndefined;

This test fails, it says:

    Expected { locator_ : {...

Read the entire recipe Recipe added 1 day ago