Follow the below steps to use ECMAScript 2015 (formerly known as ECMAScript 6) while writing gulp file. Step 1: From gulp 3.9 version onwards we can use ECMAScript 2015, so make sure you installed the latest version of gulp into your project. Check the gulp version before proceeding, run the following command at root of…
JAVASCRIPT
In this article we are not discussing how to develop forms in Angular 2, we are going to discuss how to write a custom validator for Angular 2 forms. Forms API in Angular 2 has some built-in validators already, here is an model driven form example with built-in required validator.
I am using Underscore.js from long time, it’s a JavaScript library that provides useful functional programming helpers without extending any built-in objects. I recently came across it’s templating capabilities. Underscore provides _.template() function to dynamically build markup from a template and some data(JavaScript objects). Here is the syntax: _.template(templateString, [settings]) _.template() compiles JavaScript templates into functions…
Dealing with dates is always a nightmare. In this example I will show how to convert a JSON date to JavaScript date returned from server side to an AngularJS app. In AngularJS we use filters to transform data, in this case we can use angular date filter. But it doesn’t work directly with JSON formatted…
It is very simple with HTML5 Canvas API, it provides toDataURL() method. The toDataURL() method of the canvas object converts the canvas drawing into a 64 bit encoded PNG URL. We can pass “image/jpeg” as argument to toDataURL() method, to get image data URL in the jpeg format. Here is the code snippet which explains…
The $http service is a core angular service that helps in consuming web services (either REST or SOAP) via the browser’s XMLHttpRequest object or via JSONP . $http service is similar to jQuery $.ajax() method. Here is the syntax of $http service : The $http service is a function which takes a single argument that…
I was working with AngularJS from couple months. I came across some new features in AngularJS 1.2. I am going blog about this new features. AngularJS 1.2 introduces new “controller as” syntax. This syntax helps us to abstracts the use of $scope in controllers, simplifying the syntax of controllers, html markup. Let’s have a look…
In my application I am calling an action method from JavaScript & expecting result as JSON. This is pretty simple in ASP.NET MVC, Once we get response object in action method we can call Json() method pass response object as a parameter, then it will transform your response object as JSON & return it as…
This article is about how to send json object to asp.net controller action method & bind it to strongly typed .NET object. We have many mechanism to do this. Bind json encode string to System.Object, write logic to decode the json encoded string & bind it to Model or ViewModel. Write custom model binder with…