Posts

Make it Easy by Angular-JS Directive to Format or Filter Date

Image
There is always a havoc on handling dates in the application either it's java /dot net or angular . So here is the best way I found in order to overcome the problem . Date Directive Here I am going to explain about angular date filtering concept and how to  use filtering concept to filter Date across your application.It is always better to create a date.js file for those filtering concept.  The advantage of this is you can very easily filter the data anywhere in your view by just placing directive. This can be achieved by using following code in your module defined, for example : CYW.date below. angular.module('CYW.date', []) .filter('stringToDate', function () { return function (input) { /// gets Date input, if not, returns null. Also sets the date to /// correct format if (!input) return null; var date = moment(input); return date.isValid() ? date.format('MM/DD/YYYY') : null; }; }

C# 7.0 Potential Features – Tuples

Image
In this article, let's discuss on Tuple Class in C# and the potential new proposals that are being considered for C#7. Potential Features - Tuple What is Tuple in C#? Basically, a  tuple  ( Tuple in C# ) is an ordered sequence, immutable, fixed-size and of heterogeneous objects, i.e., each object being of a specific type. The  tuples  are not new in programming. They are already used in F#, Python, and databases. A tuple allows you to combine multiple values of possibly different types into a single object without having to create a custom class. This can be useful if you want to write a method that for example returns three related values but you don’t want to create a new class. System.Tuples namespace supports Tuple class in C#. The purpose of a tuple is to create a way to return multiple values from a function. class CodeYourWayTupleDemo { static void Main() { // Create three-item tuple. Tuple tuple = new Tuple (10, "Code

Read CSV file content using Angular Directive.

Image
This demo shows how to read a CSV file and get its content into scope by using angular . Let's consider the view where we will be having Upload control and that's very simple code . Below would be the HTML file. If you notice the  accept   attribute on file upload control above forces the browser to accept files type  .CSV  but again user can change it anytime and select another file . Have a validation for file type if you want to restrict to CSV only  Now Let's define the Controller File which reads the input type .  For Demo Purpose I am just copying all contents into scope .Choose your implementations according to Your need !!  Result of Code  : CodeYourWay Page

Some of the time-saving tips every AngularJS user should know !! - Part 2

Image
Must Read  before Reading this Post : Some of the time-saving tips every AngularJS user should know !! - Part 1  . As Discussed in Earlier post  ,It was all about High/Architecture level Tips . Let's go through some Low-Level thoughts. At a Low-Level Thoughts/Tips/Gotchas: 1) Learn and love your console logs - Sometimes, especially with the digest cycles and angular lifecycle, it's sometimes easier to print your debugs to a console.logs instead of adding breakpoints. It's faster! 2) Get Batarang  , the chrome extension -   That is by far the best way to get into the bowels of AngularJS, and some of the details it provides (performance, dependencies) will make your life super simple and easy 3) Start running your unit tests on every save -   It will do the work of the compiler, and next time you break any functionality, you can fix it with a simple Undo in your IDE 4) Use the [] notation for listing your dependencies -  That is angularA

Some of the time-saving tips every AngularJS user should know !! - Part 1

Image
Having worked on and with AngularJS for short period thou , here are some of the time-saving tips at the top of my mind , Just go ahead and comment out if you find it wrong or if you have any : At a high / architecture level: 1)   Write your tests ! - Stop, right now.I mean it !!!. ;)  Don't Ever go by this Saying !!! You can never be 100% right Always write your unit tests. In Javascript, you don't have the compiler to hand hold you and tell  you did something wrong.  And you will want to pull your hair out the next time your app is broken because of a missing letter.And the larger your application gets, having the comfort of making large scale changes and refactorings without worrying about broken functionality is amazing! And writing your unit tests is the only way to get there! 2)   Don't put too many things on the scope .  The scope is expensive, as it is the one that undergoes dirty checks. Just put exactly what will be displayed on the UI