How to create a dropdown in AngularJS with Symfony object as options -


i want create dropdown options based symfony object. know it's relatively easy create dynamic dropdown angular alone (creating model based variable , using ng-options in .twig) issue object coming symfony object.

here's code far:

insightcontroller.php

public function indexaction(request $request) {     $user = $this->tokenstorage->gettoken()->getuser();     $apps = $this->getuserapps($user);      return $this->templating->renderresponse('insight/index.html.twig', ['apps' => $apps]); } 

index.html.twig

<select data-placeholder="all apps" chosen style="width:300px;" ng-model="app">     <option value="" ng-selected="true">all apps</option>     <optgroup label="my apps">         {% app in apps if app.user_id == currentuserid %}         <option value='{{ { site_key: app.site_key, secret_key: app.private_key }|json_encode()|raw }}'>{{ app.app_name|default(app.domain) }}</option>         {% endfor %}     </optgroup>     <optgroup label="other apps">         {% app in apps if app.user_id != currentuserid %}             <option value='{{ { site_key: app.site_key, secret_key: app.private_key }|json_encode()|raw }}'>{{ app.app_name|default(app.domain) }}</option>         {% endfor %}     </optgroup> </select> 

app.js

$scope.app = { site_key: null, secret_key: null }; //app model 

current behavior of code not change value of dropdown whenever select other options , null. not select 'all apps' default selected option.

i'm thinking should handle front-end option selection first (ng-change?).

any appreciated.

thanks!


Comments

Popular posts from this blog

Sort a complex associative array in PHP -

vb.net - How to ignore if a cell is empty nothing -