My Previous Articles
I have used the following method in this article:
- Used MVC Web API.
- AngularJs Filter.
SQL Script is available in part 1 (link is given above)
View page Index.cshtml
- Here I have used filter for description.
I placed filter:search in my ng-repeat and used in description text box ng-model ="search.ProductDescription".
- <table class='table table-bordered'>
- <tr>
- <th>Name</th>
- <th>Description</th>
- <th colspan="2">Action</th>
- </tr>
- <tr>
- <th>
- <label for="description">Filter By Description-> </label>
- </th>
- <th>
- <input type="text" ng-model="search.ProductDescription" placeholder="Enter Description" class="form-control"></th>
- <th colspan="2"></th>
- </tr>
- <tr ng-repeat="Product in Products | filter:search ">
- <td>{{ Product.ProductName}}</td>
- <td>{{ Product.ProductDescription}}</td>
- <td><span><a href="javascript:void(0);" ng-click="edit(Product);">
- <img width="16" height="16" alt="Close" src="Image/Edit.jpg" /></a></span></td>
- <td><span><a href="javascript:void(0);" ng-click="delete(Product.Id);">
- <img width="16" height="16" alt="Close" src="Image/close.png" /></a></span></td>
- </tr>
- </table>
- public ActionResult Index()
- {
- return View();
- }
- Here I have written method for getting data from my model.
- public class ProductInfoAPIController : ApiController
- {
- private readonly TestProductEntities db = new TestProductEntities();
- // GET: api/ProductInfoAPI
- public string GetProductInfos()
- {
- var serializer = new JavaScriptSerializer();
- return (serializer.Serialize(db.ProductInfoes.ToList()));
- }
- }
Service.js
- Below I have declared get service for fetching data.
- Also my Controller.js and App.js is same as my previous article.
- I have attached the source code.
- app.factory('AngularService', ['$http', function ($http) {
- return {
- get: function () {
- return $http({
- method: 'GET',
- headers: {
- 'Content-Type': 'application/json; charset=utf-8'
- },
- url: '/api/ProductInfoAPI/GetProductInfos',
- data: {}
- });
- },
- };
- ]);
Output
You can also test the output here.


To Pho GaPosted Oct 19, 2015, 11:39 PM EDT
Thanks sir :)
Santhakumar MunuswamyPosted Oct 17, 2015, 10:49 PM EDT
Good one
Rupali ShindePosted Oct 15, 2015, 3:12 AM EDT
nice
Sibeesh VenuTOP 100Posted Oct 15, 2015, 12:13 AM EDT
Thanks for sharing
Kunal PatelPosted Oct 14, 2015, 10:58 PM EDT
Thanks to all.
Mukesh KumarPosted Oct 14, 2015, 10:29 PM EDT
Thanks for sharing
Ankit BansalPosted Oct 14, 2015, 8:48 PM EDT
nice..thanks for sharing
Humayun Kabir MamunPosted Oct 14, 2015, 8:14 PM EDT
Nice...
Ravi PatelPosted Oct 14, 2015, 8:45 AM EDT
good one
Priyaranjan K STOP 100Posted Oct 14, 2015, 8:27 AM EDT
Nice Share ..
Nilesh JadavPosted Oct 14, 2015, 8:16 AM EDT
Good work sir !!!
RakeshPosted Oct 14, 2015, 7:53 AM EDT
Good Share