ANGULARJS Controller
The AngularJS controller controls the data for the AngularJS application.
The AngularJS controller is a regular JavaScript object
<h2>AngularJS Controller Properties</H2><div Ng-app= "" ng-controller= "mycontroller"> <p>Name:<input type="text" ng-model="Person.name"></P> <p>Gender:<input type="text" ng-model="Person.sex"> </P> <div>Information:{{person.info()}} </div></div><script type="Text/javascript"> function mycontroller($scope){ $scope. person = {name:"Lanfe ng ", Sex:" female ", Info:function(){var x; x = $scope. person; return x.name + ""+ x.sex; } } } </script><h2>AngularJS Controller method</H2><div Ng-app= "" ng-controller= "mycontroller"> <p>Name:<input type="text" ng-model="Person.name"></P> <p>Gender:<input type="text" ng-model="Person.sex"></P> <div>Information:{info()}} </div></div><script type="Text/javascript"> function mycontroller($scope){ $scope. person = {name:"Lanfe ng ", Sex:" female " }; $scope. info=function(){var x; x = $scope. person; return x.name + ""+ x.sex; } } </script>
ANGULARJS Filter
Currency format numbers as currency formats.
Filter selects a subset from the array item.
The lowercase formatted string is lowercase.
Order by to arrange an array based on an expression.
Uppercase formatted string is uppercase.
Filters can be added to an expression by a pipe character (|) and a filter.
<h2>AngularJS Controller method</H2><div Ng-app= "" ng-controller= "mycontroller"> <p>Name:<input type="text" ng-model="Person.name"> </P> <p>Gender:<input type="text" ng-model="Person.sex"></P> <div>Information:{{person.name |}} </div></div><script type="text /javascript ">function mycontroller($scope){ $ Scope.person = {name:"Lanfeng", Sex:"female" }} </SCRI PT>
ANGULARJS Controller and Filter Learning (iii)