使用自动创建的名称保存范围变量并附加到范围

时间:2016-02-23 02:06:34

标签: javascript angularjs angularjs-scope

在多步骤表单中,我有一个前一个,下一个指令,它获取当前步骤并将其保存在会话存储变量中。用户填写的步骤1模板上的所有信息都存储在$ scope.section1对象中。我想继续保存" section2"," section3"在每个步骤上单击下一步。如何动态生成$ scope.section1,$ scope.section2?我想保留符号" section1"," section2"等

    OSError                                   Traceback (most recent call last)
<ipython-input-10-bf04141dec86> in <module>()
      7 with urllib.request.urlopen(urlToVisit) as response:
      8     sourcePage = response.read().decode()
----> 9 df = pd.read_csv(sourcePage, skiprows=17, header=None)
     10 df.head()

/opt/conda/lib/python3.4/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, dialect, compression, doublequote, escapechar, quotechar, quoting, skipinitialspace, lineterminator, header, index_col, names, prefix, skiprows, skipfooter, skip_footer, na_values, true_values, false_values, delimiter, converters, dtype, usecols, engine, delim_whitespace, as_recarray, na_filter, compact_ints, use_unsigned, low_memory, buffer_lines, warn_bad_lines, error_bad_lines, keep_default_na, thousands, comment, decimal, parse_dates, keep_date_col, dayfirst, date_parser, memory_map, float_precision, nrows, iterator, chunksize, verbose, encoding, squeeze, mangle_dupe_cols, tupleize_cols, infer_datetime_format, skip_blank_lines)
    496                     skip_blank_lines=skip_blank_lines)
    497 
--> 498         return _read(filepath_or_buffer, kwds)
    499 
    500     parser_f.__name__ = name

/opt/conda/lib/python3.4/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
    273 
    274     # Create the parser.
--> 275     parser = TextFileReader(filepath_or_buffer, **kwds)
    276 
    277     if (nrows is not None) and (chunksize is not None):

/opt/conda/lib/python3.4/site-packages/pandas/io/parsers.py in __init__(self, f, engine, **kwds)
    588             self.options['has_index_names'] = kwds['has_index_names']
    589 
--> 590         self._make_engine(self.engine)
    591 
    592     def _get_options_with_defaults(self, engine):

/opt/conda/lib/python3.4/site-packages/pandas/io/parsers.py in _make_engine(self, engine)
    729     def _make_engine(self, engine='c'):
    730         if engine == 'c':
--> 731             self._engine = CParserWrapper(self.f, **self.options)
    732         else:
    733             if engine == 'python':

/opt/conda/lib/python3.4/site-packages/pandas/io/parsers.py in __init__(self, src, **kwds)
   1101         kwds['allow_leading_cols'] = self.index_col is not False
   1102 
-> 1103         self._reader = _parser.TextReader(src, **kwds)
   1104 
   1105         # XXX

pandas/parser.pyx in pandas.parser.TextReader.__cinit__ (pandas/parser.c:3246)()

pandas/parser.pyx in pandas.parser.TextReader._setup_parser_source (pandas/parser.c:6111)()

控制器:

$sessionStorage[currindex] = $scope.section1;  

指令:

$scope.nextPage = function(){
           var currindex = $scope.getIndex();
          var nextindex = ++currindex;
         //storing in session    
        $sessionStorage[currindex] = $scope.section1;   
    }

1 个答案:

答案 0 :(得分:1)

使用[]代替.之类的内容

$scope.nextPage = function(){
       var currindex = $scope.getIndex();
      var nextindex = ++currindex;
     //storing in session    
    $sessionStorage[currindex] = $scope['section' + currindex];   
}

这就是你要找的东西吗?