json动态菜单和路由

i would load my menù from json file and add routing dynamically; i try this code but don't work: When I loading this menu..i would to create dynamic routing with ui-routing of angularjs; Thank's in Advanced. Marco.

setup.js.php

<?php
  session_start();
  $menu = file_get_contents("layout/menu/mymenu.json");

  header("content-type: application/javascript");
 ?>

 angular.module('erp.Setup', []).constant('Setup', {
    username:    '<?php print USER_NAME; ?>',
    menu:      '<?php print $menu; ?>'   <---- Uncaught SyntaxError:   Unexpected token ILLEGAL
 });

My json:

{
  "menu": {
     "_id": "menu_1",
       "item": [
        {
          "title": "Test item1",
          "subtit": "Subtitle 1",
           "color": "red",
           "icon": "fa-menu",
           "link": "#/m_item1"
        }
       ]
   }
}

For your solution I believe the quotes in the '<?php print $menu; ?>' are making it a string, so you will need to be careful about the formatting of your Json.

Moreover, here is a sample navigation I created for my test app. Hope this helps you:-

My Directive:-

var todoApp = angular.module("todoApp",[]);

todoApp.directive('ngNavPills',function(){
var dtv={};

dtv.restrict='A';
dtv.replace=true;
dtv.scope={ ngModel:'=' };
dtv.template='<ul class="nav nav-pills"><li ng-repeat="itm in ngModel" role="presentation"><a ng-href="{{itm.link}}">itm.name</a></li></ul>';
dtv.link= function($s,$e,$a){

}
return(dtv);
});

My Navigation Json:-

[{"name":"Home","link":"/Index.html"},{"name":"Index2","link":"/Index2.html"},{"name":"Index3","link":"/Index3.html"}]

Usage:-

<div ng-nav-pills></div>