Multiple controllers with AngularJS in single page app

前端 未结 7 746
不思量自难忘°
不思量自难忘° 2020-12-22 16:44

I want to know is how to use multiple controllers for a single page application. I have tried to figure it out and I\'ve found questions very similar to mine, but there is j

7条回答
  •  醉酒成梦
    2020-12-22 17:29

    You could also have embed all of your template views into your main html file. For Example:

    
      

    Test App

    This way if each template requires a different controller then you can still use the angular-router. See this plunk for a working example http://plnkr.co/edit/9X0fT0Q9MlXtHVVQLhgr?p=preview

    This way once the application is sent from the server to your client, it is completely self contained assuming that it doesn't need to make any data requests, etc.

提交回复
热议问题