离子/角度不能从api

时间:2016-04-04 20:54:38

标签: angularjs json

我无法看到并获取数据而不显示

这是控制器代码

angular.module("薄膜模块&#34)

.controller("电影 - 控制器",功能($ scope,电影){

var initView = function(){

    var film1 = Film.build({"Title":"The Martian","Year":"2015","Rated":"PG-13","Released":"02 Oct 2015","Runtime":"144 min","Genre":"Adventure, Drama, Sci-Fi","Director":"Ridley Scott","Writer":"Drew Goddard (screenplay), Andy Weir (book)","Actors":"Matt Damon, Jessica Chastain, Kristen Wiig, Jeff Daniels","Plot":"During a manned mission to Mars, Astronaut Mark Watney is presumed dead after a fierce storm and left behind by his crew. But Watney has survived and finds himself stranded and alone on the hostile planet. With only meager supplies, he must draw upon his ingenuity, wit and spirit to subsist and find a way to signal to Earth that he is alive.","Language":"English, Mandarin","Country":"USA, UK","Awards":"Nominated for 7 Oscars. Another 31 wins & 161 nominations.","Poster":"http://ia.media-imdb.com/images/M/MV5BMTc2MTQ3MDA1Nl5BMl5BanBnXkFtZTgwODA3OTI4NjE@._V1_SX300.jpg","Metascore":"80","imdbRating":"8.1","imdbVotes":"383,169","imdbID":"tt3659388","Type":"movie","Response":"True"});

    var film2 = Film.build({"Title":"Inception","Year":"2010","Rated":"PG-13","Released":"16 Jul 2010","Runtime":"148 min","Genre":"Action, Mystery, Sci-Fi","Director":"Christopher Nolan","Writer":"Christopher Nolan","Actors":"Leonardo DiCaprio, Joseph Gordon-Levitt, Ellen Page, Tom Hardy","Plot":"A thief, who steals corporate secrets through use of dream-sharing technology, is given the inverse task of planting an idea into the mind of a CEO.","Language":"English, Japanese, French","Country":"USA, UK","Awards":"Won 4 Oscars. Another 139 wins & 192 nominations.","Poster":"http://ia.media-imdb.com/images/M/MV5BMjAxMzY3NjcxNF5BMl5BanBnXkFtZTcwNTI5OTM0Mw@@._V1_SX300.jpg","Metascore":"74","imdbRating":"8.8","imdbVotes":"1,405,608","imdbID":"tt1375666","Type":"movie","Response":"True"});

            $scope.films = [film1, film2];
    };

    $scope.$on("$ionicView.loaded", function(){

        initView();
    });
});

和模型:

angular.module("电影模型",[])

.factory(" Film",function(){

    function Film(title,year, runtime, director,actors, plot,poster,imdbRating) {

        this.title = title;
        this.year = year;
        this.runtime = runtime;
        this.director = director;
        this.actors = actors;
        this.plot = plot;
        this.poster = poster;
        this.imdbRating = imdbRating;

    }

    Film.build = function(data){

        if (!data)
        return null;
        return new Film(data.title,data.year,data.runtime, data.director, data.actors, data.plot, data.poster, data.imdbRating);

    }
    Film.prototype.toJson = function(){

        return angular.toJson(this);

    }
    Film.fromJsonBunch = function(data){
        if (angular.isArray(data)){
            return data.map(Film.build).filter(Boolean);
      }    
      return Film.build(data);
    }

    return Film;

})

这是html:

    

    <ion-list>
        <ion-item ui-sref="app.films-details" ng-repeat="film in films">{{film.title}}</ion-item>

    </ion-list> 
</ion-content> 

1 个答案:

答案 0 :(得分:0)

当您将“标题”定义为“标题”时,您正在使用“标题”。 JavaScript属性区分大小写。尝试更改它,看看是否有效。