ng-repeat在iOS中无效

时间:2014-01-31 15:55:50

标签: javascript ios jquery-mobile cordova web-sql

我有ng-repeat看起来像这样:

<div ng-repeat = "Header in Headers" ng-show = "Headers.length > 0">
            <div class = "promoHeader">
                {{Header.Descript1}}
            </div>
            <div class="touchcarousel minimal-light promosCarousel">
                <ul class="touchcarousel-container">
                    <li ng-repeat = "Promo in Header.Promos" class="touchcarousel-item" ng-class = "{'disabledPromo' : invalidPromo(Promo)}">
                        <a id = "{{Promo.PromoID}}" ng-click = "viewPromo(Promo)">
                            <img class = "tcimage" ng-src = "{{Promo.PhotoURL}}"/>
                            <div class = "tctext"><span class = "tctext-inner">{{Promo.Descript1}}</span></div>
                        </a>
                    </li>
                </ul>
            </div>
        </div>

出于某种原因Header.Descript1取值为Promo.Descript1。没有意义的是它在Android中正常工作但在iOS中断了。这是cordova 3.3.0应用jQuery Mobileangularjs。我看了DOM中的weinre,但这没有帮助。也许iOSangularjs之间存在兼容性问题?

修改

问题似乎是WebSQL而非angular

造成的
db.transaction(function(tx){
                tx.executeSql('SELECT * FROM PromoHead INNER JOIN Promo ON PromoHead.HeadID = Promo.HeadID ORDER BY PromoHead.SortOrder', [], function (tx, results){
                    for (var i = 0; i<results.rows.length; i++)
                    {
                            headers.push({
                                HeadID : results.rows.item(i).HeadID,
                                Descript1 : results.rows.item(i).Descript1, 
                                Promos : []
                            });
                    }
                }, errorCB); 
            }, errorCB);

我检查了PromoHead并且它具有正确的值。但是,当我执行此inner join时,PromoHead会获取结果中第一行Promo的值。此错误仅发生在iOS上,android按预期工作。

2 个答案:

答案 0 :(得分:1)

属性定义周围的空格可能会导致问题

答案 1 :(得分:0)

通过从PromoHead

明确说明我需要的列来解决问题
tx.executeSql('SELECT PromoHead.HeadID, PromoHead.Descript1, PromoHead.SortOrder FROM PromoHead INNER JOIN Promo ON PromoHead.HeadID = Promo.HeadID ORDER BY PromoHead.SortOrder'...