简体   繁体   English

AngularJs项目无法作为单页Web应用程序使用

[英]AngularJs project not working as a single page web app

I'm trying to integrate AngularJs to a existing web project(jquery). 我正在尝试将AngularJs集成到现有的Web项目(jquery)。 This is a part of my code : 这是我的代码的一部分:

<div class="medya" ng-repeat="d in data" masonry-item-dir>
  <a href="{{d.Url}}" class="onizleme"><img src="{{d.Image}}" alt="Içerigin Basligi" data-src="{{d.Image}}" srcset="{{d.Image}} 1x, {{d.Image}} 2x"></a>
  <div class="govde">
    <a href="{{d.Url}}" class="baslik">{{d.Title}}</a>
    <div class="bilgi"><a href="{{d.Url}}" class="lnk">{{d.EditorName}}</a> <span data-title="{{d.DateCreated}}" class="tooltip">{{d.CreateDate}}</span></div>
    <div class="aciklama">{{d.Content}}</div>
    <div class="alt">
      <span class="damga" title="{{d.ReadCount}} Görüntüleme"><span class="icon-eye"></span>{{d.ReadCount}}b</span>
      <a class="imle tooltip aktif" href="{{d.Url}}"><span class="icon-bookmark"></span></a>
    </div>
  </div>
</div>

This is not working as a single page application, it sends a new request and opens a new page everytime a link is clicked. 它不能用作单页应用程序,它会发送新请求并在每次单击链接时打开一个新页面。 I guess it's because of the a href="{{d.Url}}" parts I'm using. 我猜是因为我正在使用a href="{{d.Url}}"部分。 How can I change it in order to make it a single page site? 如何更改它以使其成为单个页面的网站?

A single page application needs to be able to change pages "internally". 单个页面应用程序需要能够“内部”更改页面。 This is usually handled by a router module. 这通常由router模块处理。

There are three main choices for AngularJS: AngularJS有三个主要选择:

  1. UiRouter - I would highly recommend this as it is the most feature rich and well supported by the community. UiRouter-我强烈建议您这样做,因为它是功能最丰富且得到社区广泛支持的功能。
  2. ngRoute - This is the default Angular 1.x router. ngRoute-这是默认的Angular 1.x路由器。 This router lacks many features of other routers. 该路由器缺乏其他路由器的许多功能。
  3. Component-Router - This is a back port of the Angular2 Component Router. 组件路由器 -这是Angular2组件路由器的后端口。 The API may not be the most stable. API可能不是最稳定的。

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

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