Home » JavaScript (page 20)

JavaScript

Secrets of the JavaScript Ninja – Debugging JavaScript

Web Code Geeks have partnered with Manning to provide you this ebook with a 39% discount! Check at the end of the article for the relevant code! In this article, excerpted from Secrets of the JavaScript Ninja, Second Edition, we introduce you to some of the tools that can be used for debugging JavaScript. For a long time, the development ...

Read More »

Angular.js Transclusion Example

There is a myth that wants transclusion to be a hard concept to understand and manage, according to Angular.js. So, for today, we’ll wear the hat of Mythbusters, by displaying several simple examples of transclusion in Angular.js. 1. Introduction First things first, which means that we have to understand the term itself, in order to delve into tougher/technical questions that ...

Read More »

Javascript Callback Function Example

By now you are all aware that functions in Javascript are first-class objects, which means that they behave like any other object: they can be stored in variables, be passed as arguments, or be returned from other functions. Because of this peculiar quality of theirs, they can be passed as arguments to other functions, which is the essence of callback ...

Read More »

The best way for sharing data between controllers in AngularJS 1.x

You may know the situation in AngularJS 1.x when multiple independent controllers need to share some data. E.g. one controller adds some data that should be available in the other controllers in the same view. So far as I know there are three possibilities: Using $scope, e.g. $scope of a common parent controller or $rootScope Using publish-subscribe design pattern via ...

Read More »

Three Shades of Angular

In 2014 I presented at the Atlanta Code Camp and walked through building an AngularJS app starting from file … new. I used test-driven development to demonstrate how to create a functional application. I also wanted to demonstrate an app with multiple controllers that communicate with each other yet don’t rely on $scope, $watch, or even event broadcasting. You can view ...

Read More »

Object Oriented Javascript Tutorial

While typically programming is a set of rules based on certain actions and logic, with time, programmers realized that everyday problems might need a somehow different approach in order to be solved efficiently. That is where Object Oriented Programming comes to play. But what is OOP? Let’s discuss it below!         What is Object Oriented Programming? OOP ...

Read More »

Mock responses to HTTP calls with network traffic simulation by using ngMockE2E

The AngularJS’ module ngMockE2E allows to fake HTTP backend implementation for unit testing and to respond with static or dynamic responses via the when API and its shortcuts ( whenGET, whenPOST, etc). In this post, I will only demonstrate how to respond to any HTTP calls by mocking the responses. We will also see how the network load can be simulated. Such behavior gives ...

Read More »

jQuery getJSON example

The goal of this example is to show you how to use the jQuery .getJSON() method. The JavaScript Object Notation (JSON) is a data interchanging format. JSON is a set of key/value pairs, the value may be a string, boolean, number, object or an array. As an example look at this personal information in json format: {"name":"maykel","age":25}. To get the ...

Read More »