Pages

Friday, 6 July 2018

AngularJS : Using $http service to get JSON data


No. Name Rate
{{ $index + 1 }} {{x.name}} {{x.rate}}
  • {{ x.name + ', ' + x.rate }}

Thursday, 5 July 2018

AngularJS : $interval Service Example


The time is:

{{ theTime }}

The $interval service runs a function every specified millisecond.

AngularJS : $http Service

Data from server :

{{ myServerData }}

The $http service requests a page on the server, and the response is set as the value of the "myServerData" variable.

AngularJS: ServerData

Hello AngularJS programmers ...

AngularJS : Sort an Array Based on User Input

Click on the table header name to sort the data.

Name Country
{{x.name}} {{x.country}}

AngularJS - Filter an Array Based on User Input

This is one of awesome features of AngularJS filter. We can filter an array of data based on user input.

For example:
Type a letter in the input field:

  • {{ x }}

Use filter in AngularJS directive

Let's say we have this raw data :

$scope.names = [
        {name:'Jani',country:'Norway'},
        {name:'Carl',country:'Sweden'},
        {name:'Margareth',country:'England'},
        {name:'Hege',country:'Norway'},
        {name:'Joe',country:'Denmark'},
        {name:'Gustav',country:'Sweden'},
        {name:'Birgit',country:'Denmark'},
        {name:'Mary',country:'England'},
        {name:'Kai',country:'Norway'}
        ];


<ul>
  <li ng-repeat="x in names | orderBy:'country'">
    {{ x.name + ', ' + x.country }}
  </li>
</ul>

Example:
Looping with objects:
  • {{ x.name + ', ' + x.country }}

Use AngularJS ng-click event in Blogger Example

This post embedded AngularJS code to demonstrate the use of ng-click.

Klik sini kalau berani >> {{firstname}}

AngularJS in Blogger : Validate user input

The ng-model, can be used to validate user input (required, email, number).

For example:




Email: Not a valid e-mail address

Wednesday, 4 July 2018

Use AngularJS in Blogger Example


Quantity:

Costs:

Total in dollar: {{ quantity * price | currency }}

Example of using ng-repeat ...
  • {{ x.name + ', ' + x.country }}