我似乎无法在html上显示范围变量,特别是$ scope.r。我只能通过ng-repeat获得范围变量,但不能单独获得。 $ scope.r是从SupportSQLiteDatabase-beginTransaction()检索的纯js对象。我也可以从html中的ng-model对象获取值,但不能从ng-repeat指令中未使用的javascript文件中获取范围变量。我做错了吗?
<script src="https://github.com/typicaljoe/taffydb/raw/master/taffy.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.3/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<label class="item item-input item-stacked-label">
<span class="input-label">Definition</span>
<input ng-model="def" ng-value="{{r.defn}}" type="text" placeholder="New Definition ">
</label>
<label class="item">
<span>English Translation</span>
</label>
<label class="item item-input">
<textarea placeholder="English Meaning">
{{r.etrans}}{{r.defn}}
{{def.length}}{{def.charAt(0)}}
{{wdc({ch:def.charAt(0)}).first().allch}}{{wdc({ch:def.charAt(0)}).count()}}
</textarea>
</label>
&#13;
这里是javascript
var defs = TAFFY([]);
var emptydb=false;
defs.store('wdic');
.controller('ListController', ['$scope', '$http', '$state', '$location',
function($scope, $http, $state,$location) {
$http.get('js/wdc.json').success(function(data) {
$scope.wdc2 = TAFFY(data);
$scope.whichartist=$state.params.aId;
$scope.data = { showDelete: false, showReorder: false };
$scope.defs=defs;
$scope.r =$scope.defs({___id:$state.params.aId}).first();
$scope.defs().each(function (r) {console.log(r.defn+'~'+r.___id)});
console.log("here"+$scope.r.etrans);
$scope.addurl ="#/tab/list/add";
$scope.wdc=TAFFY([
{
"id": 1,
"ch": "a",
"basech": "a",
"allch": "a,ā,á,à"
},
{
"id": 2,
"ch": "à",
"basech": "a",
"allch": "a,ā,á,à"
},
{
"id": 3,
"ch": "ā",
"basech": "a",
"allch": "a,ā,á,à"
},
{
"id": 4,
"ch": "á",
"basech": "a",
"allch": "a,ā,á,à"
}
]);
});
}]);