Friday, 13 November 2015

AngularJs

AngularJs


ng-app
ng-controller
ng-model




ng-app -
Initialize the angular app.

ng-init -
Initialize the angular app data.

ng-model -
Bind the html elements like input, select, text area to angular app model.

 





ng-disabled Directive - Disables a given control.
ng-disabled

ng-show Directive - Shows a given control.
ng-show

ng-hide Directive - Hides a given control.
ng-hide

ng-click Directive - Represents a AngularJS click event.
Ng-click


Events

ng-dbl-click
ng-mousedown
ng-mouseup
ng-mouseenter
ng-mouseleave
ng-mousemove
ng-mouseover
ng-keydown
ng-keyup
ng-keypress
ng-change

ng-switch-when

Application Module - used to initialize an application with controller(s).

var mainApp = angular.module("mainApp", []);

Controller Module - used to define the controller.

mainApp.controller("studentController", function($scope) {});

Use Modules

<div ng-app="mainApp" ng-controller="studentController">
<input type="text" ng- model="student.firstName">


Validate Data checking in form


The following can be used to track error.

$dirty - states that value has been changed(check it should be focused).
$invalid- states that value entered is invalid.
$error- states the exact error.



ng-view Directive

<div ng-app="mainApp">
    ...
    <div ng-view></div>
</div>

Ng-template Directive    

The ng-template directive is used to create an HTML view using script tag. It
contains idattribute which is used by $routeProvider to map a view with a controller.

<div ng-app="mainApp">
...
    <script type="text/ng-template" id="addStudent.htm">
    <h2> Add Student </h2>
        {{message}}
    </script>
</div>



What are Filters in AngularJS?
Filters are used to format data before displaying it to the user. They can be used in view templates, controllers, services and directives.
There are some built-in filters provided by AngularJS like as Currency, Date, Number, OrderBy, Lowercase, Uppercase etc.

What are Expressions in AngularJS?
AngularJS expressions are much like JavaScript expressions, placed inside HTML templates by using double braces such as: {{expression}}.

AngularJS evaluates expressions and then dynamically adds the result to a web
page. Like JavaScript expressions, they can contain literals, operators, and variables

There are some valid AngularJS expressions:
{{ 1 + 2 }}
{{ x + y }}
{{ x == y }}
{{ x = 2 }}
{{ user.Id }}

1 comment:

  1. You know.. Its cute idea of sharing the things.. Its really awesome.. Go ahead.. share more..

    ReplyDelete