简体   繁体   English

AngularJS-动态添加视图及其路径和控制器

[英]AngularJS - Dynamically adding views along with their routes and controllers

I am building an application where I'll be getting JSON file containing content. 我正在构建一个应用程序,将在其中获取包含内容的JSON文件。 From that JSON, I will create a view(html), bind it to a controller and route that are to be created when I receive the JSON. 从该JSON,我将创建一个view(html),将其绑定到控制器,并路由接收到JSON时要创建的控制器。 It will be a list of items where each item leads to a different view, controller and route. 这将是一个项目列表,其中每个项目都导致不同的视图,控制器和路线。

I need help in implementing this dynamic behavior in the application. 我需要在应用程序中实现这种动态行为的帮助。

Much appreciated! 非常感激!

EDIT: 编辑:

I forgot to mention that this is to be implemented in an Ionic Application 我忘了提到这将在离子应用程序中实现

Just a quick thought... 只是想了一下...

  • Remove the ng-app attribute. 删除ng-app属性。 This will prevent angular to bootstrap automatically. 这将防止角度自动引导。
  • Call for the JSON using XMLHttpRequest 使用XMLHttpRequest调用JSON
  • use the retrieved data in the application config to build your routes 使用应用程序配置中检索到的数据来构建路线
  • manually start the angular application calling angular.bootstrap More 手动启动的角应用程序中调用angular.bootstrap 更多

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM