0

我正在开发 android 应用程序AngularJsJQuery Mobile使用JQM-AngularJS Adapter和用于服务器端,我JayData用来生成DataBase然后哑数据WebSql。现在我想在运行时从webSql我的数据中获取数据,DropDowns但它无法初始化DropDowns这里是我生成的 mu 代码

下拉代码

<ul data-role="listview" data-inset="true" ng-controller="foodSelection">
    <li><span>Catagory</span>
        <select id="selectCatagoryFood" data-role="listview" data-native-menu="true"
            ng-init="foodCatagory = foodCatagories.cast[0]"
            ng-options="foodCatagory as foodCatagory.text for foodCatagory in foodCatagories.cast"
            ng-model="foodCatagory"
            ng-change="changeFoodCatagory()">
        </select>
    </li>
</ul>

Angular 和 JayData 代码

var myApp = angular.module('myApp',[]);
myApp.factory('foodCatagories',function(){
     var foodCatagories = {};
     foodCatagories.cast = [
     {
         value: "000",
         text: "Select Any"
    }
    ];
return foodCatagories;
});
myApp.controller('foodSelection',function($scope,foodCatagories){
$scope.foodCatagories = foodCatagories; // First Add Dummy Data
_context.onReady(
{
    success:function()
            {   //Context For Getting Data -- JayData Method --
                _context.FoodGroup.forEach(function(FG)
                {
                    //Get Data From WebSql
                        console.log(FG.FoodGroupID);
                        console.log(FG.Description);

                }).then(function()
                {
                 // Now Here I want To Dumped in to dropdown
                });
            },
    error: function (error)
           {
               alert(error);
               console.log(error);
               alert("error");
           }
}).then(function(){

});
$scope.changeFoodCatagory = function(){
    alert($scope.foodCatagory.value);
}
});

我需要运行时数据,所以我应该怎么做?

4

0 回答 0