从WebSql获取AngularJs中的数据

时间:2013-10-04 22:36:06

标签: javascript jquery-mobile angularjs jaydata angularjs-factory

我正在使用AngularJsJQuery MobileJQM-AngularJS Adapter开发Android应用,而对于服务器端,我使用JayData生成DataBase,然后在WebSql中生成哑数据{1}}。 现在我想在运行时从webSql获取数据到DropDowns,但无法在DropDowns初始化这里是我生成的mu代码

DropDown代码

<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);
}
});

我需要关于运行时的数据,那么我该怎么做呢?

0 个答案:

没有答案