Saturday, 29 March 2014

AngularJS : Calendar UI using AngularJS Tutorials

                                                   AngularJS



Following links for AngularJS Calendar UI.

JSFiddle Calendar Demo Tutorials


Github Calendar UI Concept

Saturday, 1 February 2014

AngularJS: How to create simple form using AngularJS.

Simple form using AngularJS


Form is a collection of controls for the purpose of grouping related controls together.

Form and controls provide validation services, so that the user can be notified of invalid input. This provides a better user experience, because the user gets instant feedback on how to correct the error. Keep in mind that while client-side validation plays an important role in providing good user experience, it can easily be circumvented and thus can not be trusted. Server-side validation is still necessary for a secure application.

The key directive in understanding two-way data-binding is ngModel. The ngModel directive provides the two-way data-binding by synchronizing the model to the view, as well as view to the model.

index.html

<!doctype html>
<html ng-app>
   <head>
         <script src="http://code.angularjs.org/1.0.4angular.min.js"></script>
         <script src="script.js"></script>
  </head>
  
<body>

  <form novalidate class="simple-form">

   Name:<input type="text" ng-model="user.name" /><br />

   E-Mail: <input type="email" ng-model="user.email" /><br />

   Gender <input type="radio" ng-model="user.gender" value="male" / >Male

   <input type="radion" ng-model="user.gender" value="female" />Female<br />

   <button ng-click="reset()">Reset</button>

   <button ng-click="update(user)">Save</button>

</form>

<pre>form = {{user | json}}</pre>

<pre>master = {{master | json}}</pre>

</div>

</body>

</html>

script.js

function controller($scope) {

$scope.master = {}'

$scope.update = function(user) {

$scope.master = angular.copy(user);

};

$scope.reset = function() {

$scope.user = angular.copy($scope.master);

};

$scope.reset();

}

AngularJS: Difference Between Angular Expressions and JS Expressions

Angular Expressions vs JS Expressions


It might be tempting to think of Angular view expressions as Javascript expressions, but that is not entirely correct, since angular does not use a Javascript eval() to evaluate expressions. You can think of Angular expressions as Javascript expressions with following diffences:

1.Attirbute Evaluation: 
                              
                             Evaluation of all properties are against the scope, doing the evaluation, unlike in Javascript where the expressions are evaluate against the global window.

2.Forgiving

             Expression evaluation is forgiving to undefined and null, unlike in Javascript, where such evaluations generate NullPointerExceptions.


3.No Control Flow Statements

             You can pass result of expression evaluations through filter chains. For example to convert date object into a local specific human-readable format.

If, on the other hand, you do want to run arbitrary Javascript code, you should make it a controller method and call the method. If you want to eval() an angular expression from JavaScript, use the $eval() method.

index.html

<!doctype html>
 <html ng-app>
     <head>
         <script src="http://code.angularjs.org/1.0.4angular.min.js"></script> 
     </head>
     <body>
               1+2={{1+2}}

     </body>       
 </html>

Result:

1+2 = 3

You can try evaluating different expressions here:

index.html

<!doctype html>
<html ng-app>
     <head>
           <script src="http://code.angularjs.org/1.0.4angular.min.js"></script>
           <script src="script.js"></script>
     </head>
     <body>
           <div ng-controller="expcnt" class="expressions">

            Expression:

            <input type="text" ng-model="expr" size="80" />

             <button ng-click="addExp(expr)">Evaluate</button>

              <ul>

                   <li ng-repeat="expr in exprs">

                     [<a href="" ng-click="removeExp($index)">X</a>]

                     <tt>{{expr}}</tt> => <span ng-bind="$parent.$eval(expr)"></span>
                    </li>

                 </ul>

               </div>

           </body>

        </html>


script.js

function expcnt($scope) {

var exprs = $scope.exprs = [];

$scope.expr = '3*10 | currency';

$scope.addExp = function(expr) {

exprs.push(expr);

};

$scope.removeExp  = function(index) {

 exprs.splice(index,1);

};

}

Saturday, 4 January 2014

Angularjs Tutorials - Filter AngularJS

                                                     How use fileters in angularjs

Filters perform data transformation. Typically they are used in conjunction with the locale to format the data in  locale specific output.

index.html

<!doctype html>

<html ng-app>

        <head>

                <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>

        </head>

        <body>

                <div ng-init= "list = ['iPhone ', 'HTC','Samaung','Nokia']">
               
                 Number formatting : {{1234567890 | number}} <br>

                Array filtering <input ng-model="predicate">

                {{ list | filter:predicate | json}}

                </div>
        </body>
</html>
  


refer : jsfiddle work place


Wednesday, 27 November 2013

AngularJS : How to connect AngularJS with MySQL database

                                             How to connect angularjs with MySql database

Now, we are discusses about connect angularjs with backend. It is one of the way to connect database. AngularJS is one of the powerful web application framework. The angularjs is reducing the backend overload.

Understanding the angularjs concept  refer previous tutorials. Easy to understanding server loading data examples:

1.Without AngularJS Web application performance :


First diagram, without using angularjs concept  building web applications diagram. This diagram explains, server workload high and  performance low and response time is very high.


2. With AngularJS web application performance:


Second diagram, building web applications with angularjs - server work load very low and performance very high and response time is very quick processes.

The angularjs is get all data from database and its make JSON(Java Script Object Notation) format.

The connecting angularjs with mysql database.

 First method call to controller site.



sample code :



$scope.addBook = function()
{
http({

method : 'POST',
url: 'index.php?urls',
data: {book_name : $scope.bookName, book_price : $scope.bookPrice},
headers : {'Content-type' : 'application/json'}
}).success(function(data, status, headers, config){

if(data.success)
{
$scope.books.push(data);
 }

}).error(function(data, status, headers, config){

//set error message.

});

}


addBook() is one of the method in view site. The addBook() method call to controller site.

ex:

<button ng-click = "addBook()" >Add book </button>

book_name, book_price  -> books table column names.

$scope.bookName , $scope.bookPrice -> html textbox ngmodel name.

ex:

<input type="text" ng-model="bookName">

<input type="text" ng-model="bookPrice">


Touch with me! Gain more!

Monday, 11 November 2013

AngularJS - ngAnimate in Filter Array Items 3D Rotate

                           
 AngularJS - ngAnimate in Filter Array items



In this tutorials, we are discuss about ngAnimate in filter array items. The ngAnimate with the some of the directives,

Directive name Animation type
ngRepeate enter, leave and move
ngView enter and leave
ngInclude enter and leave
ngSwitch enter and leave
ngIfenter and leave
ngShow show
ngHide hide

Filter array items in 3D rotate using ngAnimate.



index.html

<!DOCTYPE html>
<html ng-app>

<head>

<link rel="stylesheet" href="style.css">

<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">

<script src="http://code.angularjs.org/1.1.5/angular.js"></script>

</head>

<body ng-init="products=['iPhone', 'Samsung', 'HTC', 'Nokia' , 'Sony', 
 
'iPhone 5c' 'Apple', 'iPad', 'Lava', 'Surface']; ">

<div class="well">

<form class="form-search">

<input type="text" ng-model="search" placeholder="Filter items..">

<ul>

<li ng-animate=" 'animate' " ng-repeat="product in products |  filter : search">

<a href="#">{{product}}</a>

</li>

</ul>

</form> 

</div> 

</body> 

</html>


Stylesheet file. Support all borwsers.



style.css


.animate-enter,  .animate-leave {

-webkit-transition : 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;

-moz-transition : 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;

-ms-transition : 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750 ) all;

-o-transition : 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;

transition : 400ms cubic-bezier(0.250, 0.250, 0.750, 0.750) all;

position : relative;

display : block;

}


.animate-leave.animate-leave-active,

.animate-enter {

-webkit-transform : rotateX(90deg)  rotateZ(90deg);

-moz-transform : rotateX(90deg)  rotateZ(90deg);

-ms-transform : rotateX(90deg)  rotateZ(90deg);

-o-transform : rotateX(90deg) rotateZ(90deg);

transform : rotateX(90deg)  rotateZ(90deg);

opacity : 0;

height : 0px;

}

.animate-enter .animate-enter-active,

.animate-leave {


-webkit-transform : rotateX(0deg)  rotateZ(0deg);

-moz-transform: rotateX(0deg) rotateZ(0deg);

-ms-transform : rotateX(0deg) rotateZ(0deg);

-o-transform : rotateX(0deg) rotateZ(0deg);

transform: rotateX(0deg) rotateZ(0deg);

opacity : 1;

height :30px;

}



Demo -  Filter Array Items - 3D Rotate




If have any doubts about this tutorial means post comments.

Touch with me! Gain more.