search

Home  >  Q&A  >  body text

angular.js - angular单页面应用的实现方式

之前有做过一个单页面项目,当时是用ng-include把所有页面给包含进首页。
其实当时就觉得这个思路不太对,我感觉ng-include应该是用来包含一些分页面的公共页面的,比如页头和页尾。
这刚好是两个反向的思路。
那么我的问题是
1、用ng-include来做单页面应用的思路是否正确?ng-include的正确用法是否是来包含公共部分代码的?
2、如果不用ng-include,那么使用什么来写单页面应用?

原问题:ng-include的正确用法

为情所困为情所困2739 days ago602

reply all(2)I'll reply

  • 淡淡烟草味

    淡淡烟草味2017-05-15 16:54:47

    This question can be extended to the use of angular templates.
    Use of templates: http://www.zhihu.com/question/21635146/answer/18967226
    Refer to Zhihu source code: view-source:http://zhuanlan.zhihu.com/Weekly/19620215
    angular routing: http://my.oschina.net/tanweijie/blog/295111
    Angular routing implementation: http://blog.csdn.net/violet_day/article/details/16974467
    Keywords: ng-template, routeProvider

    1. Is the idea of ​​using ng-include for single-page applications correct? Is the correct usage of ng-include to include public parts of code?
    It is not.
    2. If ng-include is not used, what should be used to write a single-page application?
    angular routing routeProvider
    Angular front-end routing exists independently of the server, and nested views can use ui-router.

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-15 16:54:47

    http://stackoverflow.com/a/17544706/2586541

    http://www.bennadel.com/blog/2441-nested-views-routing-and-deep-linkin...

    reply
    0
  • Cancelreply