AngularJS filters based on PHP server side request/response -


in application i'm working on need add filters example: approved, documents, documents approved , others. these filters based on mysql queries db performed php controller (i'm using symfony2) , functions on controllers return formed json. question is: can write filters angularjs based on behavior? how? (i mean little example understand flow)

i think can similar below code:

//in symfony controll public function sampleaction() {    $data = $this->getdoctrine()->getmanager()->getrepository('yourbundle:sampleentity')->findall()->toarray();    return $this->render('yourbundle:views_path:sampletwigoutput.html.twig', array(       'data' = json_encode($data)    )); } 

in twig file can have like

<div ng-init="mydata = {{ data|raw }}"></div> <table id="sorteddata">   <tr><th>t1</th><th>t2</th></tr>   <tr ng-repeat="data in mydata | filter:sortdata">      <td>{[{data.name}]}</td>      <td>{[{data.phone}]}</td>   </tr> 

you need change start , end symbol different (like {[{ , }]}) interpolateprovider
need define sortdata js function like

angular.module('mysortmodule', []).   filter('sortdata', function() {     // stuffs sort data base on whatever want     // set them out     return out; }); 

you can find more info on angular filter

i recommend sort data in db through symfony faster , in angular output dump data


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -