Kamis, 22 Oktober 2015

Selasa, 20 Oktober 2015

Angularjs format input number when typing example

Angularjs format input number when typing example

In this example i will show how to make format input number when typing in angularjs, we will use ng-changed event to do that. Of course you also use other way to do that.
Our goal:
Input : 100 => change to 100
Input : 1000 => change to 1,000
Input : 10000 => change to 10,000
Input : 100000 => change to 100,000
.....
And
Input : 100000.450 => change to 100,000.450

I hope that after got this example you can customize and make a common function related it.

Full code here

Read more »
Baca selengkapnya

Senin, 19 Oktober 2015

Kamis, 15 Oktober 2015

Angularjs table format example

 Angularjs table format example

Requirement:
Have a list customers, show customer information (name, age, gender, phone) as a table.
To make discern base on gender: if gender = 'girl' then textcolor will be green
To make discern base on age: if age <20 background of age cell will be blue (is teen)

                                                if age >60 background of age cell will be gray(is old)

As same as following image

Here is full code, please focus at highlight chars.

Read more »
Baca selengkapnya

Senin, 12 Oktober 2015

Multi select listbox with dynamid ng-selected values

Multi select listbox with dynamid ng-selected values

 Example: we have two arrays: categories array is a list of categories and selectedcategories is a list selected categories by id. We want to use <select > to display all categories via multi selected categories which matching selectedcategories array values.

Output sample:


Here is full code 

Read more »
Baca selengkapnya

Kamis, 08 Oktober 2015

Filter by and operator in AngularJs

Filter by and operator in AngularJs

In this post I will show you how to use && operator in AngularJs.
Example I have a students list as below:

 $scope.students = [  
{ name: 'Hai', age: 25, gender: 'boy' },
{ name: 'Hai', age: 30, gender: 'girl' },
{ name: 'Ho', age: 25, gender: 'boy' },
{ name: 'Hoan', age: 40, gender: 'girl' },
{ name: 'Hieu', age: 25, gender: 'boy' }
];

I want to filter students via gender to be boy and filter by name of them.

The first I create a function named "filterbyboy" as following:

 $scope.filterbyboy = function (genderstr) {  
if ((typeof $scope.search === 'undefined')||($scope.search === ''))
return (genderstr = "")
else
return (genderstr = "boy");
};

Explaination: if not filter name then display all students else filter by input name and gender as 'boy'

Here is full HTMLcode

Read more »
Baca selengkapnya