Kamis, 29 Oktober 2015

Angularjs routing asp.net mvc example

Angularjs routing asp.net mvc example

In this article I try to make a simple example about how to apply angularjs routing for asp.net mvc application. After this you can know how to use angularjs routing and angularjs routing for MVC. Beside that you can know how to rout with parameter, how to use ng-view.
agenda:
  • Add MVC application
  • Reference angularjs to MVC application
  • Add angularjs router and angularjs controller
  • Modify _Layout.cshtml and some mvc view to use angularjs.
  • Run and see result

Read more »
Baca selengkapnya

Rabu, 28 Oktober 2015

Selasa, 27 Oktober 2015

How to use ng-paste and ng-cut?

How to use ng-paste and ng-cut?

- ng-cut is specify custom behavior on cut event.

How to apply ng-cut?

 <input ng-cut="cut=true" ng-init="cut=false; value='please cut me'" ng-model="value">  
You just cut it: {{cut}}

- ng-paste is specify custom behavior on paste event.

How to apply ng-paste?

  <input ng-paste="paste=true" ng-init="paste=false" placeholder='please paste here'>  
pasted: {{paste}}

Full code for this example as below:

Read more »
Baca selengkapnya

Senin, 26 Oktober 2015

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