Latest Angular.js Recipes

Getting $watch is not a function error in AngularJS

i'm trying to automatically update the END-DATE of my ui bootstrap datepicker when the START-DATE is greater than the END-DATE. The datepickers are inside a modal, and the function is done in AngularJS.

All the examples i've seen use $watch with...

Read the entire recipe Recipe added 54 minutes ago

ng-readonly not working in angular checkbox

Can I use ng-readonly directive in a checkbox?

The checkbox is writable even after it is decorated with ng-readonly.


<input type="checkbox" ng-model="model" ng-readonly="test" /> {{model}}



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

AngularJS + ag-grid: sticky/remembered selections with virtual paging/infinite scrolling

In an AngularJS application, I have an ag-grid that uses virtual paging/infinite scrolling to lazy-load rows from a dataset that is too large to show at once. I have turned on check-box selection in the first column, so that the user should be able...

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

Angular UI datepicker overrides placeholder text

I'd like to have custom placeholder text on the input field of my datepicker. Currently my placeholder text gets overridden by 'MM/DD/YYYY'

Here's my html:

<input type="text" id=" coverpagedatefrom" class="form-control ng-pristine ng-untouched...

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

angularjs ng-submit not working

hey i am new and already second question for today but i need help when i try puting the ng-submit inside a form its says attribute is not allowed and doesnt work ill be happy if you can help me. and if you can explain to me to when do i need to...

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

customer markers in html with ngmap Angularjs

I am doing a project, where i show plenty of ships on a map using ngmap 1.13.13 with angularjs. I want to have custom markers on my map. But I never get them on my map or if, they are not scaled. i tried different approaches, here are two of...

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

Uncaught Error: [$injector:unpr] Unknown provider: $localstorageProvider &lt;- $localstorage

Was using ionic, in my app.js I do

angular.module('starter', ['ionic', 'starter.controllers','ngCordova'])

.run(function($ionicPlatform, $localStorage , $cordovaPush) {
  $ionicPlatform.ready(function() {

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

Material angular infinite scroll with $http request

I'm using md-virtual-repeat directive of Angular Material to have an infinite scroll, and I need to replace it's demo $timeout function with a $http request. But I can't get to the right solution. In the code below, infinite scroll works fine but...

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

How to update json file in AngularJS

I want to update the existing json file in AngularJS

JSON file:

    "text1": "Click here to edit!",
    "text2": "Click here to edit!",
    "text3": "Click here to edit!",
    "text4": "Click here to edit!"  

I want to update this JSON file...

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

Fetchin data from local JSON FIle in angularjs

I want to fetch data from JSON file which is on my local machine. But I am not able to get the data. It is showing some cross domain error for $http.

Here is my code.

angular.module('myApp',[]).controller('myCtrl', function ($scope, webtest)...

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

ng-disabled is not working on span tag

There is a span tag with glyphicon icon that I want to disable.But ng-disabled is not working, that is the icon is still clickable.

<span ng-disabled="true" class="glyphicon glyphicon-trash" style="font-size:13px;" aria-hidden="true"...

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

Remove or change the calendar icon from angular material datepicker

I was using angular material. I find it very cool, well designed and user friendly. I was trying to change or remove the calendar icon on datepicker directive.

<md-datepicker ng-model="myDate" md-placeholder="Enter date" ></md-datepicker>


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

Setting up multiple forms / validations on same page

What's up all, total AngularJS noob here and looking for some answers.

I have a page set up like so:

    <form name="mainForm" class="content" ng-app="pathForm" ng-controller="FormControl" novalidate>

    <div class="full-page open" id="form1">

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

Unable to post simple string data to Web API from AngularJS

I am trying to get a json string from my angular app to a Web API. I have looked all over the internet the past 6 hours trying and failing miserably to figure out what I am doing wrong.

I have checked the network console and I can see the json as...

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

What does &#39;var vm = this;&#39; mean in angular controllers?

I was browsing some stuff on github and I saw inside controller.js, someone had put the following:

function ImageController ($scope, $timeout) {
   var vm = this;

What is this used for?

Read the entire recipe Recipe added 14 hours, 49 minutes ago from Angular 2 to ASP.NET ApiController


public string apitest([FromBody]string str)
   Console.Writeline(str); // str is always null
   return null;

Angular 2:

var creds = "str='testst'" ;
var headers = new Headers();

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

Angular Run Block - Use UI-Router $stateProvider to Resolve Promise

UI-Router is different than Angular's ngRoute. It supports everything the normal ngRoute can do as well as many extra functions.

I am changing my Angular app from ngRoute to UI-Router. But I cannot quite figure out how to inject resolve function...

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

How to use document.getElementById() method in Angularjs

I have written hide() and show() functions in javascript and calling them on onmousedown in HTML code.

Functions as below:

function show() {
  document.getElementById("formDiv").style.display = "block";

function hide() {

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

angularjs and ng-file-upload - multiple file upload with multiple ngf-select inputs


I have a form where two files can be uploaded to the server along with a Javascript object literal that is created in another form.

Its optional for these files to be uploaded so there could be none, one or two but the Javascript object...

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

How do you set pie chart colors in angular-chart.js

I am playing with the pie chart in angular-charts.js. I have made it so that I can set the data and labels. A watcher function executes whenever something is added or removed from the list of "pie" items.

Labels and data are recognized, but not the...

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

Get value in a row on click and pass it to popup

I need to get the value in a row of a table on click and display it in popup


    <table md-data-table class="md-primary" md-progress="deferred">
        <thead md-order="query.order" md-trigger="onorderchange">

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

how to upload a file in Restangularjs using multipart/formdata

my html code

<form  method="post" enctype="multipart/form-data" ng-controller="commentCtrl" name="form">
        <a href="" type="file" class="custom-height"><img src="source/assets/images/icons/icofileattached.png" class="attachmentpng-height" ...

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

Create empty object or object with null values for already known keys

I am playing around with JavaScript and AngularJS since a few days and I am not sure about the following:

I am working on a sample project in which a user is able to create a new car with just a few properties stored in an JS object like this:


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

How to retain the scroll position of ng-repeat in AngularJS when removing an item from the top

I tried to work from the solution to this

How to retain scroll position of ng-repeat in AngularJS?

to achieve retaining the scroll position when removing the top item in an ng-repeat but couldn't figure out the code to do so.

Also, side note, the...

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

How to navigate one page to another page using AngularJs

How to navigate from one page to another page. Assume i have a login page, after entering username and password fileds while click on submit button it needs to validate and if both username and password is correct it needs to go home page. Home page...

Read the entire recipe Recipe added 1 day ago