将json数据输入到ioni视图中

时间:2016-12-24 15:04:23

标签: angularjs json ionic-framework

我有这个控制器......

"use strict";

var app = angular.module('ng-laravel');
app.controller('StartCtrl',function($scope, $http,$rootScope,$ionicLoading,$cordovaDevice,$cordovaVibration,ionicToast,$ionicPlatform,$cordovaNetwork){
    $http.get('https://www.myurl.com/stringjson').
    success(function(data, status, headers, config) {
        $scope.progetti = data.items;
    }).
    error(function(data, status, headers, config) {
    // log error
    });
});

正确获取json数据,如下所示:

    [{"id":2,"titolo":"The Marriage","descrizione":"Sal, a thirteen year old girl, narrates a story told
 by her Grandfather, which begins in a hospital room after Sal\u2019s Grandmother becomes ill during
 a road trip.  The story of The Marriage Bed flashes back to small-town Kentucky, where Sal\u2019s grandparents
 first met.  Gramps feels love at first sight for Gram, and courts her for the better part of a month
 before she accepts a marriage proposal.  On the night of their wedding, Gramps and Gram find a special
 bed in their new home: the bed that had belonged to Gramps\u2019 parents, and the bed that they\u2019ve
 slept in all of their lives since.  The tale ends with Sal wondering about her own romantic future.
  ","inizio":"2016-12-17 00:00:00","fine":2016,"goal":10000,"banner":"1457196511-29619972.png","entry_by"
:1,"created_at":"2016-03-05 17:48:31","updated_at":"2016-03-06 11:33:02","funded":"0","pledged":1000
,"image":"","id_categoria":5,"staff_picked":null,"vetrina":null,"summary":"A young girl traveling with
 her Grandparents recounts a favorite family love story ","numero_finanziatori":2,"active":1,"tags":""
,"banner3":"","image2":"","image3":"","motivazione":"Vediamo se funziona","didascalia":"Prova prova"
,"rating":5,"prima":0,"id_azienda":0,"banner2":""}

这是我的观点,我无法显示数据...

    

    <div class="hero no-header flat">
        <div class="content">
            <div class="app-icon"></div>
            <h2 class="light">Welcome</h2>
            <p class="stable">Our projects</p>
        </div>
    </div>
    <ion-list>
            <ion-item ng-controller="StartCtrl" class="item-avatar">
                <h2>{{ items[0].nome}}</h2>
            </ion-item>
        </ion-list>
    <div class="padding">
        <button type="submit" class="button button-full button-assertive ink">{{ data.nome }}</button>
        <button ui-sref="login" class="button button-full button-clear button-light">back to login</button>

    </div>
</ion-content>

1 个答案:

答案 0 :(得分:0)

您正在打印错误的变量..

<ion-list>
            <ion-item ng-controller="StartCtrl" class="item-avatar">
                <h2>{{ progetti[0].titolo}}</h2>
            </ion-item>
        </ion-list> 

试试这个.. 只有$scopethis个变量会自动同步。