I am trying to build a menu containing submenus, each of them are named after my Zend controllers. My angular MenuController contains this array:
$scope.controllerNames = ['controller1', 'controller2', 'controller3'];
In my view, I want to render a Zend partial for each controller of these controllers:
<div ng-repeat="controllerName in menuCtrl.controllerNames">
<div id="submenu-{{controllerName}}">
<?php echo $this->partial('path/to/zend/partial/{{controllerName}}.phtml') ?>
</div>
</div>
I get the correct div id (e.g. "submenu-controller1"), but i can't seem to access the {{controllerName}} variable in the PHP block. I also tried to use ng-include, but the partials are not part of the public folder of the application.
Is there any way to use this angular variable in a PHP string?
You can't do that this way. I suppose that you want use in php script your angular {{controllerName}} variable. It won`t work because first is php, then browser, and then javascript. So flow looks like : request to server, php generate html and sending back, browser interpret what php send and render site, when site is rendered angular starts its work.
You can try make something like this:
$http.get('pathToYourScriptWhichRenderWhatUWant?controller='+{{controllerName}}).success(function(data) { // attach data to DOM })
But better approach is to keep all templates in frontend and only request data from backend, you don't need to keep and generate html in backend if you got angular :)