我正在使用AngularJs
,JQuery Mobile
和JQM-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);
}
});
我需要关于运行时的数据,那么我该怎么做呢?