对象不支持属性或方法' slice'茉莉

时间:2015-07-07 09:07:16

标签: angularjs jasmine karma-runner

这是我的控制器代码

The format I would like it in is:
[keyname] => [value]
If the key contains another dictionary, the function could call itself and print it out in place? The effect I’m going for here is:
When it’s a single value:
[keyname] => [ single value ]
When it’s a nested dictionary
[keyname] => 
[keyname] => [Value]
[keyname] => [value]

这是测试用例,我在这里调用$ scope.loadMajorObject

 $scope.loadMajorObjects = function () {
      var appId = $scope.currentAppId;
      var type = $scope.majorObject.type;
      if (_.isEmpty(appId))
          return;
      var cacheKey = { key: cacheKeys.objectTypeList($scope.asCacheOptions({ ObjectType: type })) };
      return dataFactory.get("/MajorObject/All?applicationId=" + appId + "&type=" + type, { cache: cacheKey })
             .then(function (result) {
                 $scope.majorObjects = result.data.data;
                 $scope.majorObjectsList = $scope.majorObjects.slice(0, $scope.itemsPerPage);
                 $scope.totalItems = $scope.majorObjects.length;
                 $scope.isLoad = true;
             });
  };

当我调用此函数时它是抛出和异常,因为对象不支持属性或方法' slice',如何纠正这个?

0 个答案:

没有答案