Как создать несколько контроллеров angularjs, используя для цикла? - PullRequest
0 голосов
/ 01 ноября 2018

Мне нужно создать несколько контроллеров на лету из данных JSON. Можно ли создать использование для цикла? Мне нравится создавать динамический виджет в adf-widget-angular-dashboard, и для каждого виджета есть один контроллер. мои данные JSON следующие:

[{
    "title": "Testwidget",
    "widgetTypes": ["PreVisitorsTrafficPrecGraph", "PreTotalPasserByGraph", "PreTotalVisitorsGraph", "PreNewUsersGraph", "PreReturnUsersGraph"],
    "description": "This is Description",
    "category": "customWidget",
    "controller": "newWidgetTimeSeriesGraphTypeCtrl",
    "controllerName": "newWidgetTimeSeriesGraphType",
    "templateUrl": "line-bar-chart1",
    "graphType": "line",
    "graphDetails": "TimeSeries"
  },
  {
    "title": "Testwidget1",
    "widgetTypes": ["SessionsPerHour"],
    "description": "This is Description1",
    "category": "customWidget",
    "controller": "newWidgetTimeSeriesGraphTypeCtrl2",
    "controllerName": "newTimeSeriesGraphType",
    "templateUrl": "line-bar-chart1",
    "graphType": "line",
    "graphDetails": "HourSeries"
  },
  {
    "title": "Testwidget2",
    "widgetTypes": ["PreTotalVisitorsGraph", "PreTotalPasserByGraph"],
    "description": "This is Description2",
    "category": "customWidget",
    "controller": "newWidgetTimeSeriesGraphTypeCtrl",
    "controllerName": "newWidgetTimeSeriesGraphType1",
    "templateUrl": "line-bar-chart1",
    "graphType": "line",
    "graphDetails": "CorelationSeries"
  },
  {
    "title": "Testwidget3",
    "widgetTypes": ["PreNewUsersGraph", "PreReturnUsersGraph"],
    "description": "This is Description3",
    "category": "customWidget",
    "controller": "newWidgetTimeSeriesGraphTypeCtrl",
    "controllerName": "newSeriesGraphType",
    "templateUrl": "line-bar-chart1",
    "graphType": "line",
    "graphDetails": "MultiSeries"
  },
  {
    "title": "Testwidget4",
    "widgetTypes": ["PreNewUsersGraph", "PreReturnUsersGraph"],
    "description": "This is Description4",
    "category": "customWidget",
    "controller": "newWidgetTimeSeriesGraphTypeCtrl",
    "controllerName": "SeriesGraphType",
    "templateUrl": "line-bar-chart1",
    "graphType": "line",
    "graphDetails": "OthersSeries"
  }
]
...