Ionic Framework:单击按钮将元素添加到另一个页面

时间:2016-12-06 23:38:15

标签: javascript angularjs json ionic-framework

对于Ionic应用程序项目,我创建了一个存储一些事件数据的json文件。该文件稍后将在应用程序中下载并本地存储在设备上,但可能会更新以提供新数据。

我使用ng-repeat指令在艺术家页面上显示数据。我面临的问题如下:每当用户点击其中一个元素上的加号按钮时,该元素应该显示在另一个页面上(最喜欢的页面类型)。什么可以解决这个问题?

HTML

  <ion-item
          ng-repeat='item in artists | filter: query' class="artist-box">
              <div class ="info-box-purple" >
                  <div class = "info-box-text">
                      <span>{{item.day | Saturday}}<br>{{item.time}}<br>{{item.stage}}</span>
                  </div>
              </div>
              <a href="#/app/artists/{{item.shortname}}">
                  <h3 class="artist-title"><span>{{item.name}}</span></h3>
                  <div class="item image item-image">
                      <img ng-src="img/artists/{{item.shortname}}.jpg" alt="{{item.name}} Photo"/>
                  </div>
              </a>
              <div><button class="add-button button button-royal ion-plus"></button></div>

          </ion-item>

控制器(单独页面上html和控制器之间的链接)

   .controller('ListController', ['$scope', '$http', '$state', function($scope, $http, $state){
        $http.get('js/data.json').success(function(data) {
            $scope.artists = data;
            $scope.pickedartist = $state.params.bandId;
        });
    }

])

JSON文件的格式

[
    {
        "festival" : "festival 1",
        "day" : "Friday",
        "time" : "17:00",
        "stage" : "Stage 1",
        "name" : "Balkan Beat Box",
        "shortname" : "Balkan_Beat_Box",
        "bio" : "Balkan Beat Box (BBB) is an Israeli musical group founded by Tamir Muskat, Ori Kaplan and now including Tomer Yosef as a core member. The group plays Mediterranean-influenced music that incorporates Jewish, Eastern Europe (mainly Balkan) and Middle Eastern traditions, Gypsy punk, reggae and electronica. As a musical unit they often collaborate with a host of other musicians both in the studio as well as live.",
        "facebook" : "https://www.facebook.com/balkanbeatbox",
        "schedule" : "+"

    },{
        "festival" : "festival 1",
        "day" : "Friday",
        "time" : "18:00",
        "stage" : "Stage 2",
        "name" : "Blick Bassy",
        "shortname" : "Blick_Bassy",
        "bio" : "Born in 1974, singer, songwriter, guitarist and percussionist Blick Bassy grew up with 20 siblings in Cameroon’s capital Yaoundé, a city where people from all parts of the country come together, and the first languages are French and English. Bassy says: “People in Yaoundé lose their traditions and culture rapidly because they don’t speak in their mother tongues with each other or their children. My family is part of the Bassa ethnic group, a nomad tribe that originally comes from Egypt and has descendents down in South Africa. But nowadays people stay in one place because they need visas to cross borders. The word ‘bassa’ means ‘people from the earth’.”",
        "schedule" : "+"
    },{
        "festival" : "festival 1",
        "day" : "Friday",
        "time" : "19:00",
        "stage" : "Stage 3",
        "name" : "Clueso",
        "shortname" : "Clueso",
        "bio" : "Thomas Hübner (born April 9, 1980), better known by his stage name Clueso (pronounced [klyˈzo]), is a German singer, rapper, songwriter and producer. Born in Erfurt, he started performing at the age of 15. His first album Text und Ton was released in 2001. In 2011, Clueso released his album An und für sich, which reached number 2 on the German Top 100. In 2016, he released his latest album Neuanfang, peaking at number 1 on the German Top 100. His music is notable for being a mix of hip hop, pop and electronic music, and sometimes reggae.",
        "schedule" : "-"
    }]

0 个答案:

没有答案