Category Archives: AngularJs blog

AngularJs show hide on click


AngularJs show hide on click : It is very simple to call show hide on button click event in AngularJs. You can use ng-hide, ng-show to show hide the element. Here we are going to create a function and call this function on button click to hide show functionality in angularJs. Here we are going to explain the show hide functionality with example.


AngularJs show hide Div on click

Here is simple example of show hide on button click in AngularJs –

AngularJs show hide on click example


Div Show Hide Example......

Angularjs get element by id


Angularjs get element by id : You can use the angular.element(‘#element_id’); to get the element by id where #element_id is id of element. Here we are going to explain this with example.


Angularjs get element by id example

Here is an alternative of javascript document.getElementById in angularjs –

Angularjs get element by id

var currentElement = angular.element('#element_id');

Angularjs get current date time


Angularjs get current date time: You can get current date time in angularjs on Html template and javascript both. Here we have explained both the Html template date time and javascript date time with syntax and example.


Angularjs get current date time

You can get current date time in angularjs as :

Get current date time on Html template in AngularJs :

You can get current date time on html template as below :

Angularjs get current date time Syntax

{{ date_expression | date : format : timezone}}

Example:

Current date time on html Example

Current Date : {{CurrentDate | date:'dd/MM/yyyy'}}
24 Hrs Current Date Time : {{CurrentDate | date:'HH:mm:ss'}}
12 Hrs Current Date Time : {{CurrentDate | date:'hh:mm:ss a'}}

Which will give current date time

Get Current Date time in Angular Controller Js

You can get current date time in angularjs as :

Angularjs get current date time on js Syntax

 

dd/MM/yyyy format -
dd, MMMM yyyy format -
24 Hour time-
12 Hour time-
Note : For date format reference you can go through –Date Format Reference .

Use angularjs variable inside html tag


Use angularjs variable inside html tag : You can use the angularjs variable inside the html tags. Here is simple example in which we have used angularjs variable to assign the dynamic id of the div element. Below is detailed example.


Assign angularjs variable inside html tag

You can use the angularjs variable inside the html tag as below –

Angularjs variable inside html tag

Counter :: {{$index + 1}} Data :: {{data}}

Here you can also add your own condition on the basis of counter.

Angularjs counter in ng-repeat


Angularjs counter in ng-repeat : You can get index of loop ie. counter of the loop in
AngularJs or ionic framework simply using the $index variable. Here we are going to explain the method how to get loop count in AngularJs or Ionic Framework.


Angularjs counter in ng-repeat

You can get the loop index in angularjs or in ionic framework as below –

Angularjs counter in ng-repeat

Counter :: {{$index + 1}} Data :: {{data}}

Here you can also add your own condition on the basis of counter.

AngularJs ng-change event


AngularJs ng-change event example : AngularJs ng-change event binds change event with elements in html.


Here is the AngularJs ng-change event example

The below example shows the ng-change event directive.

Example

 



  
  
  

Changed Value : {{ finalValue }}

Try it »

AngularJs ng-change event example

AngularJs ng-change event example

AngularJs ng-keypress event example


AngularJs ng-keypress event example : AngularJs ng-keypress event binds keypress event with elements in html.


Syntax : AngularJs ng-keypress event

The below example shows the ng-keypress event directive.

Example

    



Counter = {{i}}

Try it »

AngularJs ng-keypress event example

AngularJs ng-keypress event example

AngularJs ng-keydown event example


AngularJs ng-keydown event example : AngularJs ng-keydown event binds keydown event with elements in html.


Syntax for AngularJs ng-keydown event example

The below example shows the ng-keydown event directive.

Example

    



Counter = {{i}}

Try it »

AngularJs ng-keydown event example

AngularJs ng-keydown event example

AngularJs ng-keyup event example


AngularJs ng-keyup event example : AngularJs ng-keyup event binds keyup event with elements in html.


Syntax : AngularJs ng-keyup event

The below example shows the ng-keyup event directive.

Example

    



Counter = {{i}}

Try it »

AngularJs ng-keyup event example

AngularJs ng-keyup event example