Friday, 8 May 2015

ionic inputs

Text

First up is the Text Input, the most common input type used. The code is pretty standard, and if you’re used to web development this input isn’t anything new. This is also the fallback if a device does not support a certain HTML input type.


 <label class="item item-input">
  <span class="input-label">Username</span>
  <input type="text">
</label>


Email

The Email Input should be used anytime you require a user to enter an email address. It’s important to take advantage of this input type because it offers a much smoother keyboard experience, displaying the @ and . characters within the initial keypad for quicker typing.


 <label class="item item-input">
  <span class="input-label">Email</span>
  <input type="email">
</label>



Tel

The Tel Input is a very unknown and underused input type. It displays a full numeric keypad, which makes for a great user experience when all that is required from the user is numbers. Take advantage of this one!


 <label class="item item-input">
  <span class="input-label">Telephone</span>
  <input type="tel">
</label>


Search

The Search Input doesn’t do anything too different from the text input except change the standard “go” button to read “search” instead.


<label class="item item-input">
  <i class="icon ion-search placeholder-icon"></i>
  <input type="search" placeholder="Search">
</label>



Number

The Number Input is another way to offer numbers for your users. The difference between the number input and the tel input is that also offers easy access to special characters and symbols. However, if you only need numbers entered, it’s best to stick with the tel input.



<label class="item item-input">
  <span class="input-label">Number</span>
  <input type="number">
</label>



Date

The Date Input should be utilized for when a user is asked to enter the month, day, and year. The mobile keyboard will offer a nice interactive panel for easy entering.


<label class="item item-input">
  <span class="input-label">Date</span>
  <input type="date">
</label>


Month

The Month Input will trigger a keyboard experience similar to the date input, however it leaves out the “day” option. Use this input when your user only needs to enter the month and year. A perfect example would be for taking credit card expiration dates.


 <label class="item item-input">
  <span class="input-label">Month</span>
  <input type="month">
</label>


Password

The Password Input is another commonly used input in normal web development. It hides the characters so nobody else can see what the user is typing.



 <label class="item item-input">
  <span class="input-label">Password</span>
  <input type="password">
</label>


Friday, 1 May 2015

http request

What is HTTP?

The Hypertext Transfer Protocol (HTTP) is designed to enable communications between clients and servers.
HTTP works as a request-response protocol between a client and server.
A web browser may be the client, and an application on a computer that hosts a web site may be the server.
Example: A client (browser) submits an HTTP request to the server; then the server returns a response to the client. The response contains status information about the request and may also contain the requested content.



Two HTTP Request Methods: GET and POST

Two commonly used methods for a request-response between a client and server are: GET and POST.
  • GET - Requests data from a specified resource
  • POST - Submits data to be processed to a specified resource

 Simple GET request example :


$http.get('/someUrl').
  success(function(data, status, headers, config) {
    // this callback will be called asynchronously
    // when the response is available
  }).
  error(function(data, status, headers, config) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
  });

 Simple POST request example (passing data) :


$http.post('/someUrl', {msg:'hello word!'}).
  success(function(data, status, headers, config) {
    // this callback will be called asynchronously
    // when the response is available
  }).
  error(function(data, status, headers, config) {
    // called asynchronously if an error occurs
    // or server returns response with an error status.
  });



In addition, you can supply a headers property in the config object passed when calling $http(config), which overrides the defaults without changing them globally.

To explicitly remove a header automatically added by $httpProvider.defaults.headers on a per request basis, Use the headers property, setting the desired header to undefined. For example:

 var req = {
 method: 'POST',
 url: 'http://example.com',
 headers: {
   'Content-Type': undefined
 },
 data: { test: 'test' }
}

$http(req).success(function(){...})
      .error(function(){...});



Friday, 24 April 2015

Trim data in angularjs

If we want to trim data in angularjs and data fetched from the back-end then,include following filter in controller.js


 controller.js


.filter('cut', function () {
return function (value, wordwise, max, tail) {
if (!value) return '';

max = parseInt(max, 10);
if (!max) return value;
if (value.length <= max) return value;

value = value.substr(0, max);
if (wordwise) {
var lastspace = value.lastIndexOf(' ');
if (lastspace != -1) {
value = value.substr(0, lastspace);
}
}

return value + (tail || ' …');
};
});


And where you want to trim data in html page ,please include following:-

 a)If you want to ignore some later after spaces
{{expression.name| cut:true:100:'...' }}

b) If you want complete data
{{expression.name| cut:false:100:'...' }}

Saturday, 18 April 2015

Ionic back arrow+hide data+history clear

 

 For adding the back arrow with out any text:-

 Firstly include following in the menu.html

 <ion-nav-back-button class="button-clear">
            <i class="ion-arrow-left-c arrow_size"></i>
        </ion-nav-back-button>
        </ion-nav-buttons side="left">
    </ion-nav-bar>

</ion-nav-buttons>
 
 Then include following in the app.js
 
 .config(function ($ionicConfigProvider){
 
 $ionicConfigProvider.backButton.text('').icon('').previousTitleText(false);
 
})
 
 

For hiding field from html page if that field has no data:-

 Include following in html page

 <div ng-show=”name == ‘myName’”>Some data</div> 

For clear history:-

Include following in the controller.js,for which you want to clear history

$ionicViewService.clearHistory();
 
 
 

Friday, 10 April 2015

Ionic list

Hi,
Here i am integrate expandable list in my project,like i have created a list and now i have to some child of each row into the list.When i will click on the any row of the list that time it will show its child elements with the expandable effect and other row's child element will hide.

 index.html

<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Ionic Accordion</title>
  
    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>

  </head>

  <body ng-controller="M<html ng-app="ionicApp">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>Ionic Accordion</title>
  
    <link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
    <script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>

  </head>

  <body ng-controller="MyCtrl">
   
    <ion-header-bar class="bar-positive">
      <h1 class="title">Accordion List</h1>
    </ion-header-bar>

    <ion-content>

      <ion-list>
        <div ng-repeat="group in groups">
          <ion-item class="item-stable"
                    ng-click="toggleGroup(group)"
                    ng-class="{active: isGroupShown(group)}">
              <i class="icon" ng-class="isGroupShown(group) ? 'ion-minus' : 'ion-plus'"></i>
            &nbsp;
            Group {{group.name}}
          </ion-item>
          <ion-item class="item-accordion"
                    ng-repeat="item in group.items"
                    ng-show="isGroupShown(group)">
            {{item}}
          </ion-item>
        </div>
      </ion-list>

    </ion-content>
     
  </body>
</html>
   
    <ion-header-bar class="bar-positive">
      <h1 class="title">Accordion List</h1>
    </ion-header-bar>

    <ion-content>

      <ion-list>
        <div ng-repeat="group in groups">
          <ion-item class="item-stable"
                    ng-click="toggleGroup(group)"
                    ng-class="{active: isGroupShown(group)}">
              <i class="icon" ng-class="isGroupShown(group) ? 'ion-minus' : 'ion-plus'"></i>
            &nbsp;
            Group {{group.name}}
          </ion-item>
          <ion-item class="item-accordion"
                    ng-repeat="item in group.items"
                    ng-show="isGroupShown(group)">
            {{item}}
          </ion-item>
        </div>
      </ion-list>

    </ion-content>
     
  </body>
</html>

Css

  body {
  cursor: url('http://ionicframework.com/img/finger.png'), auto;
}

.list .item.item-accordion {
  line-height: 38px;
  padding-top: 0;
  padding-bottom: 0;
  transition: 0.09s all linear;
}
.list .item.item-accordion.ng-hide {
  line-height: 0px;
}
.list .item.item-accordion.ng-hide-add,
.list .item.item-accordion.ng-hide-remove {
  display: block !important;
}


js


angular.module('ionicApp', ['ionic'])

.controller('MyCtrl', function($scope) {
  $scope.groups = [];
  for (var i=0; i<10; i++) {
    $scope.groups[i] = {
      name: i,
      items: []
    };
    for (var j=0; j<3; j++) {
      $scope.groups[i].items.push(i + '-' + j);
    }
  }
 
  /*
   * if given group is the selected group, deselect it
   * else, select the given group
   */
  $scope.toggleGroup = function(group) {
    if ($scope.isGroupShown(group)) {
      $scope.shownGroup = null;
    } else {
      $scope.shownGroup = group;
    }
  };
  $scope.isGroupShown = function(group) {
    return $scope.shownGroup === group;
  };
 
});

Friday, 27 March 2015

Angularjs directive

a

directive in  module ng

Modifies the default behavior of the html A tag so that the default action is prevented when the href attribute is empty.
This change permits the easy creation of action links with the ngClick directive without changing the location or causing page reloads,


 e.g.: <a href="" ng-click="list.addItem()">Add Item</a>


form

  1. - directive in module ng
Directive that instantiates FormController.
If the name attribute is specified, the form controller is published onto the current scope under this name.

Alias: ngForm

In Angular, forms can be nested. This means that the outer form is valid when all of the child forms are valid as well. However, browsers do not allow nesting of <form> elements, so Angular provides the ngForm directive which behaves identically to <form> but can be nested. This allows you to have nested forms, which is very useful when using Angular validation directives in forms that are dynamically generated using the ngRepeat directive. Since you cannot dynamically generate the name attribute of input elements using interpolation, you have to wrap each set of repeated inputs in an ngForm directive and nest these in an outer form element.

CSS classes

  • ng-valid is set if the form is valid.
  • ng-invalid is set if the form is invalid.
  • ng-pristine is set if the form is pristine.
  • ng-dirty is set if the form is dirty.
  • ng-submitted is set if the form was submitted.
Keep in mind that ngAnimate can detect each of these classes when added and removed.

Submitting a form and preventing the default action

Since the role of forms in client-side Angular applications is different than in classical roundtrip apps, it is desirable for the browser not to translate the form submission into a full page reload that sends the data to the server. Instead some javascript logic should be triggered to handle the form submission in an application-specific way.
For this reason, Angular prevents the default action (form submission to the server) unless the <form> element has an action attribute specified.
You can use one of the following two ways to specify what javascript method should be called when a form is submitted:
  • ngSubmit directive on the form element
  • ngClick directive on the first button or input field of type submit (input[type=submit])
To prevent double execution of the handler, use only one of the ngSubmit or ngClick directives. This is because of the following form submission rules in the HTML specification:
  • If a form has only one input field then hitting enter in this field triggers form submit (ngSubmit)
  • if a form has 2+ input fields and no buttons or input[type=submit] then hitting enter doesn't trigger submit
  • if a form has one or more input fields and one or more buttons or input[type=submit] then hitting enter in any of the input fields will trigger the click handler on the first button or input[type=submit] (ngClick) and a submit handler on the enclosing form (ngSubmit)
Any pending ngModelOptions changes will take place immediately when an enclosing form is submitted. Note that ngClick events will occur before the model is updated. Use ngSubmit to have access to the updated model.

Animation Hooks

Animations in ngForm are triggered when any of the associated CSS classes are added and removed. These classes are: .ng-pristine, .ng-dirty, .ng-invalid and .ng-valid as well as any other validations that are performed within the form. Animations in ngForm are similar to how they work in ngClass and animations can be hooked into using CSS transitions, keyframes as well as JS animations.
The following example shows a simple way to utilize CSS transitions to style a form element that has been rendered as invalid after it has been validated:
//be sure to include ngAnimate as a module to hook into more
//advanced animations
.my-form {
  transition:0.5s linear all;
  background: white;
}
.my-form.ng-invalid {
  background: red;
  color:white;
}

Directive Info

  • This directive executes at priority level 0.

Usage

  • as element:
    <form
      [name=""]>
    ...
    </form>
     
     
     

    input

    1. - directive in module ng
    HTML input element control. When used together with ngModel, it provides data-binding, input state control, and validation. Input control follows HTML5 input types and polyfills the HTML5 validation behavior for older browsers.

    Usage

    • as element:
      <input
        ng-model=""
        [name=""]
        [required=""]
        [ng-required=""]
        [ng-minlength=""]
        [ng-maxlength=""]
        [ng-pattern=""]
        [ng-change=""]
        [ng-trim=""]>
      ...
      </input>
       
       
       
       
      
      
      
      
      
      
      

      input[checkbox]

      1. - input in module ng
               HTML checkbox.

      Directive Info

    • This directive executes at priority level 0.

    Usage

    <input type="checkbox" ng-model="" [name=""] [ng-true-value=""] [ng-false-value=""] [ng-change=""]>
     
     

    input[date]

    1. - input in module ng
    Input with date validation and transformation. In browsers that do not yet support the HTML5 date input, a text element will be used. In that case, text must be entered in a valid ISO-8601 date format (yyyy-MM-dd), for example: 2009-01-06. Since many modern browsers do not yet support this input type, it is important to provide cues to users on the expected input format via a placeholder or label.
    The model must always be a Date object, otherwise Angular will throw an error. Invalid Date objects (dates whose getTime() is NaN) will be rendered as an empty string.
    The timezone to be used to read/write the Date instance in the model can be defined using ngModelOptions. By default, this is the timezone of the browser.


     

    Usage

    <input type="date"
           ng-model=""
           [name=""]
           [min=""]
           [max=""]
           [required=""]
           [ng-required=""]
           [ng-change=""]>

     

Thursday, 12 March 2015

Git Basic and Tags

Initializing a Repository in an Existing Directory

git init

Cloning an Existing Repository

If you want to get a copy of an existing Git repository—for example, a project you’d like to
contribute to—the command you need is git clone
You clone a repository with git clone [URL]. For example, if you want to clone the Ruby
Git library called Grit, you can do so like this:

git clone git://github.com/sonam/grit.git


That creates a directory named grit,initializes a *git directory inside it, pulls down all
the data for that repository, and checks out a working copy of the latest version.

Recording Changes to the Repository


You have a bona fide Git repository and a checkout or working copy of the files for that project.
Remember that each file in your working directory can be in one of two states: tracked or
untracked. Tracked files are files that were in the last snapshot; they can be unmodified, modi-
fied, or staged. Untracked files are everything else—any files in your working directory that
were not in your last snapshot and are not in your staging area. When you first clone a repository,
all of your files will be tracked and unmodified because you just checked them out and haven’t
edited anything.



Checking the Status of Your Files

git status

Tracking New Files

git add [name of file]

Skipping the Staging Area


git commit -a -m "message"

Viewing the Commit History

After you have created several commits, or if you have cloned a repository with an existing
commit history, you’ll probably want to look back to see what has happened.

git log

or 

git log --stat

One of the more helpful options is -p  which shows the diff introduced in each commit.
You can also use -2 ,which limits the output to only the last two entries:

git log -p -2

Undoing Things

At any stage, you may want to undo something. Here, I’ll review a few basic tools for undoing
changes that you have made. Be careful, because you can’t always undo some of these undos.
This is one of the few areas in Git where you may lose some work if you do it wrong.

Changing Your Last Commit

One of the common undos takes place when you commit too early and possibly forget to add
some files, or you mess up your commit message. If you want to try that commit again, you
can run commit with the --amend option:

git commit --amend

This command takes your staging area and uses it for the commit.
And then you can add and commit that file.

Adding Remote Repositories

git remote add  [URL]

Fetching and Pulling from Your Remotes

git fetch [remote-name]

Pushing to Your Remotes

git push origin master


Listing Your Tags



git tag

Creating Tags

Git uses two main types of tags: lightweight and annotated. A lightweight tag is very much like
a branch that does not change—it’s just a pointer to a specific commit. Annotated tags, how-
ever, are stored as full objects in the Git database. They’re check-summed; contain the tagger
name, e-mail, and date; have a tagging message; and can be signed and verified with GNU Pri-
vacy Guard (GPG). It’s generally recommended that you create annotated tags so you can have
all this information; but if you want a temporary tag or for some reason don’t want to keep the
other information, lightweight tags are available too.



Annotated Tags

Creating an annotated tag in Git is simple. The easiest way is to specify -a when you run the
tag command:

git tag -a [name of tag] -m "message"

Signed Tags

You can also sign your tags with GPG, assuming you have a private key.

git tag -s [name of tag] -m "message"

Lightweight Tags

Another way to tag commits is with a lightweight tag.This is basically the commit checksum
stored in a file—no other information is kept.

git tag [name of tag] -lw

Verifying Tags

To verify a signed tag

git tag -v [name of tag]

Sharing Tags

 The git push command does not transfer tags to remote servers. You have to explic-
itly push tags to a shared server after you create them. This process is just like sharing remote
branches—you can run

git push origin [name of tag]

If you have a lot of tags that you want to push up at once

git push origin --tag