0

我似乎无法在 html 上显示范围变量,尤其是 $scope.r。我只能通过 ng-repeat 获取范围变量,但不能单独获取。$scope.r 是从TaffyDB 记录对象中检索到的纯 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>

这是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,ā,á,à"
        }
      ]);      
    });
}]);
4

0 回答 0