简体   繁体   中英

AngularJs project not working as a single page web app

I'm trying to integrate AngularJs to a existing web project(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. 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.

There are three main choices for AngularJS:

  1. UiRouter - I would highly recommend this as it is the most feature rich and well supported by the community.
  2. ngRoute - This is the default Angular 1.x router. This router lacks many features of other routers.
  3. Component-Router - This is a back port of the Angular2 Component Router. The API may not be the most stable.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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