Using the latest ng library, I tried the following.
This file:
<!DOCTYPE html>
<html>
<head>
<title>Listing 4-2</title>
<script src="js/angular.min.js"></script>
<script>
function MyFilterDemoCtrl($scope) {
var someData = {
firstName: 'JENNA',
surname: 'GRANT',
dateJoined: new Date(2010, 2, 23),
consumption: 123.659855,
plan: 'super-basic-plan'
};
$scope.data = someData;
}
</script>
</head>
<body ng-app ng-controller="MyFilterDemoCtrl">
<p>
<!-- Unfiltered data -->
<strong>First Name</strong>: {{data.firstName}}<br/>
<strong>Surname:</strong> {{data.surname}}
</p>
<p>
<!-- Filtered data -->
<strong>First Name</strong>: {{data.firstName | lowercase}}<br/>
<strong>Surname:</strong> {{data.surname | lowercase }}
</p>
</body>
</html>
Displays this output:
First Name: {{data.firstName}}
Surname: {{data.surname}}
First Name: {{data.firstName | lowercase}}
Surname: {{data.surname | lowercase }}
Why?
BTW - The MyFilterDemoCtrl controller’s only task here is to make the data available to the view. As you will recall from the last chapter, placing it in the scope does this.
Thanks.
J.