函数中的$ location.path正在改变范围对象

时间:2015-07-08 23:01:33

标签: angularjs angularjs-scope

$scope.copyOrder = function() {
        console.log($scope.products);
        CopyOrder.copying = true;
        CopyOrder.orderInfo = $scope.orderInfo;
        CopyOrder.products = $scope.products;
        console.log(CopyOrder.products);
        $location.path('/newOrder');
    };

当记录$scope.products时,$scope.products[0].imprint表示$location.path是空数组。如果取出$location.path,则对象内的数组显示其中有一个对象。

基本上,$scope.products[0].imprint[0] (its length) 会在日志中显示:

$location.path

没有$scope.products[0].imprint[1]

$scope.copyOrder = function() {
        console.log($scope.products);
        $location.path('/newOrder');
    };

我正在将两个大对象从一个控制器(编辑)复制到另一个(新)。

编辑:更多代码,更少代码

$scope.products[0].imprint

当它应该有一个包含一个对象的数组时,它仍然会返回$scope.copyOrder = function() { console.log($scope.products); // shows $scope.products[0].imprint as empty console.log($scope.products[0].imprint[0]); // shows an object in an array console.log(typeof $scope.products[0].imprint); // returns object and not array $location.path('/newOrder'); } 作为一个空数组。

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class ImportCSV
{
public static void main(String[] args)
{
  //to import .csv file
  String fileName = "Ford.csv";
  File file = new File(fileName);

  try
  {
     Scanner inputStream = new Scanner(file);

     //ignore the first line
     inputStream.next();

     while (inputStream.hasNext())
     {
        //get the whole line
        String data = inputStream.next();

        //split the string into an array of strings
        String [] values = data.split(",");

        //convert to double
        double closingPrice = Double.parseDouble(values[4]);
       // System.out.println(closingPrice);

        final double EMA_12_AlPHA = 2.0 / (1 + 12);
        final double EMA_26_AlPHA = 2.0 / (1 + 26);
        double ema12 = 0;
        double ema26 = 0;
        double macd = 0;



           ema12 = EMA_12_AlPHA * closingPrice + (1 - EMA_12_AlPHA) * ema12;
           ema26 = EMA_26_AlPHA * closingPrice + (1 - EMA_26_AlPHA) * ema26;
           macd = ema12 - ema26;

           System.out.println(macd);



     }
     inputStream.close();
  }
  catch (FileNotFoundException e)
  {
     // TODO Auto-generated catch block
     e.printStackTrace();
  }

0 个答案:

没有答案