We are providing online training of realtime Live project on Asp.Net MVC with Angular and Web API. For more information click here. If you have any query then drop the messase in CONTACT FORM

Sunday, July 1, 2018

How to filter the record according name in angular js

First, we have to download of angular js library and keep the link on our HTML page

After that create the ng-app and then create the controller and write below code 


<head>
    <meta name="viewport" content = "width=device-width" />
        <title>Using AngularJs Directives and Data Binding < /title>
            < script >

        var app = angular.module("MyApp", []);
app.controller("SimpleController", function ($scope) {
    $scope.customers = [
        { name: 'Mithilesh', city: 'Hyderabad' },
        { name: 'Mohan', city: 'Delhi' },
        { name: 'Ramesh', city: 'Bangluru' }
    ];
});

</script>


    < /head>

Now we have to design our HTML page for performing our functionality and copy and paste below code


<body ng-app="MyApp">
    <div ng-controller="SimpleController">
        Name:
        <br />
        <input type="text" ng-model="name" />
        <br />
        <ul>
            <li ng-repeat="cust in customers | filter:name">{{ cust.name }} - {{ cust.city }}</li>
        </ul>
    </div>


    

</body>

Output:





No comments: