Sunday, April 24, 2016

AngularJS advanced trick and techniques

These days AngularJS is highly recommended framework for front-end developer. Angular is really awesome framework to work with. Below are few techniques those I feel really cool features and may be these are simple and easy for you but as a fresher in angular I think these features are really good.

1. How to add multiple classes in ng-class?

Everyone knows how to add class using ng-class, its very easy. We can use ng-class to have more than one class as well

 
// single class
// multiple class
some content

Similarly we can add many classes separated by comma (,)

2. Can we have multiple conditions in ng-hide and ng-show?

Yes, we can have multiple conditions in ng-hide and ng-show.

// ng-show with multiple conditions
Some content

3. How to share methods or data between controllers?

Yes we can share data and methods between controllers using Factory or Service. Angular has service as constructor method which instantiate once on startup and we can use this service/factory in any controller within the module by injecting on controller method.

Restrict input to allow only required value (jQuery plugin for input type validation)

HTML5 provides many validation on input, but still few we need to implement by our self. For example, if we need one input for price then we should allow users to enter only float values. I created one small plugin using jQuery, it is very easy to use.

To create one input with only price value then just include attribute "only-price"


To create one input with only number (contact) value then just include attribute "only-number"


Here is the codepen: http://codepen.io/JitendraPal/pen/JXBqXj

Saturday, April 2, 2016

Git Hub configuration All About

Hello Friend, Most of the time when I am working with git hub. I forgot few commands. To help myself I am writing this post, and its my pleasure if this post helps other as well.

Below are commands those are self explanatory:

  1. To clone your branch in local

    $ git clone [your git repository url]
  2. Clone specific branch in local

    $ git clone [your git repository url] -b [branch name]
  3. OR
    $ git clone -b [branch name] [your git repository url]
  4. After cloning your branch go to that branch to check branch status or perform any git operations, below command will show you current branch

    $ git branch
  5. Checkout specific branch from git

    $ git checkout [branch1]
  6. Merge branch2 into branch1

    $ git merge [branch2]
  7. Stash your changes before pull

    $ git stash
  8. Pull latest changes from current branch

    $ git pull
  9. Get stashed changes back into local

    $ git stash apply
  10. Add all your changes

    $ git add -A
  11. Add specific files

    $ git add [/file path] [/another file path] [..etc]
  12. Commit your changes with message

    $ git commit -m "[your message]"
  13. Push your committed changes in the branch

    $ git push origin [branch name]
  14. Pull latest changes

    $ git pull --rebase
  15. Create new branch and checkout in this branch

    $ git checkout -b [your new branch name]
  16. Push the branch on git hub

    $ git push origin [your new branch name]