Reputation: 1
I can't seem to get the scope variables display on the html particularly $scope.r. I can only get scope variables through ng-repeat but not individually. The $scope.r is a pure js object retrieved from TaffyDB record object. I also can get values from the ng-model object within the html but not scope variables from the javascript file not being used within the ng-repeat directive. Am I doing anything wrong?
<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>
Here's the 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,ā,á,à"
}
]);
});
}]);
Upvotes: 0
Views: 149