Angularjs-ng-model+ng-repeat Implementing the Search box

Source: Internet
Author: User

<!DOCTYPE HTML><HTMLNg-app= "MyApp">    <Head>        <MetaCharSet= "Utf-8" />        <title></title>        <Scripttype= "Text/javascript"src= "Js/angular.min.js" ></Script>        <Script>            varapp=Angular.module ('MyApp', []); App.factory ('averages', function(){                varAVGs= {}; Avgs.count=[{name:'Zhangsan', Age: *}, {name:'Lisi', Age: -}, {name:'Wangwu', Age: -                    }                ]; returnAVGs;                        }); functionAvgctrl ($scope, averages) {$scope. AVGs=averages; }        </Script>    </Head>    <Body>        <DivNg-controller= "Avgctrl">            <inputtype= "text"Ng-model= "Search.name" />            <ul>                <Ling-repeat= "Count in Avgs.count | filter:search > 

Ng-repeat can be understood as Forin, of course ng-repeat more powerful than the forin we understand.

Ng-repeat can be combined with filters for more functionality

Filter List: Filter:search find data that matches search (if string ignores case)

Sort by: ' Age ' in ascending order of Ages, by order: '-age ' in descending order of age

List interception: Limitto:2 display 2 data in positive order limitto:-2 2 data in reverse

Other filters:

Timestamp Format: date Example {{timestamp (timestamp) | date: ' YYYY-MM-DD HH:mm:ss '}}

Casing: Lowercase, uppercase example: {' abc ' | uppercase}}

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.