From an angularjs tutorial.