ANGULARJS Controller and Filter Learning (iii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.