Cordova RSS阅读器应用程序无法正常工作

时间:2014-10-31 20:40:11

标签: javascript android angularjs cordova

我正在尝试使用this great sampleCordova中为Android创建一个RSS阅读器应用。

我按照所有说明操作并在模拟器上模拟我的应用。但它只是给了我这个:

Simple RSS Reader

{{ entry.title }}

以下是index.html

的代码
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>
    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="cordova.js"></script>
    <script src="js/app.js"></script>
</head>
<body ng-app="starter">
<ion-pane>
    <ion-header-bar class="bar-stable">
        <h1 class="title">Simple RSS Reader</h1>
    </ion-header-bar>
    <ion-content ng-controller="FeedController" ng-init="init()">
        <div class="list">
            <a ng-repeat="entry in entries" class="item" ng-click="browse(entry.link)">
                <b>{{ entry.title }}</b><br>
                <span ng-bind-html="entry.contentSnippet"></span>
            </a>
        </div>
    </ion-content>
</ion-pane>
</body>
</html>

这是我的app.js内容

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services']);

rssApp.controller("FeedController", function($http, $scope) {

    $scope.init = function() {
        $http.get("http://ajax.googleapis.com/ajax/services/feed/load",
            { params: { "v": "1.0", "q": "http://blog.nraboy.com/feed/" } })
            .success(function(data) {
                $scope.rssTitle = data.responseData.feed.title;
                $scope.rssUrl = data.responseData.feed.feedUrl;
                $scope.rssSiteUrl = data.responseData.feed.link;
                $scope.entries = data.responseData.feed.entries;
                window.localStorage["entries"] = JSON.stringify(data.responseData.feed.entries);
            })
            .error(function(data) {
                console.log("ERROR: " + data);
                if(window.localStorage["entries"] !== undefined) {
                    $scope.entries = JSON.parse(window.localStorage["entries"]);
                }
            });
    };
    $scope.browse = function(v) {
        window.open(v, "_system", "location=yes");
    }
});

有没有人知道如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

确定。借助博客所有者@ nic-raboy的帮助,我设法解决了这个问题。问题出在模块行中:

angular.module('starter', ['ionic', 'starter.controllers', 'starter.services']);

'starter.controllers''starter.services'属于离子样本,我不得不从线上删除它们。所以我这样解决了:

angular.module('starter', ['ionic'])
    .controller("FeedController", function($http, $scope) {

现在它工作正常。