我正在开发 android 应用程序AngularJs
,JQuery 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);
}
});
我需要运行时数据,所以我应该怎么做?