<script>
var app = angular.module('plunker', ["ngStorage"]);
app.controller('MainCtrl', function($scope,$localStorage) {
$scope.tablelist = [{"tablename":"t1"},{"tablename":"t2"}]
if($localStorage.tableArray === undefined){
$localStorage.tableArray = []
}
if($localStorage.tableslist===undefined){
$localStorage.tableslist=[]
}
$scope.getTable=function(table){
table.btnClass = table.btnClass == "btn-danger" ? "btn-success" : "btn-danger"
var exists=false;
angular.forEach($localStorage.tableArray, function (list,$index) {
if ((list.tablename == table.tablename)) {
console.log(list.tablename)
console.log(table.tablename)
exists=true;
$localStorage.tableArray.splice($index,1)
$localStorage.tableArray.splice($index,1)
return false
}
});
if(!exists){
$localStorage.tableslist.push(table)
$localStorage.tableArray=$localStorage.tableslist;
$scope.$storage=$localStorage.tableArray
console.log($localStorage.tableArray)
table.color="red"
}
}
});
答案 0 :(得分:1)
每次点击都会在 ...
File "/usr/local/lib/python3.4/dist-packages/matplotlib/figure.py", line 1005, in add_subplot
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/matplotlib/axes/_subplots.py", line 73, in __init__
self._axes_class.__init__(self, fig, self.figbox, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/core.py", line 49, in __init__
self.patch = self.coords.frame.patch
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/frame.py", line 129, in patch
self._update_patch_path()
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/frame.py", line 115, in _update_patch_path
self.update_spines()
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/frame.py", line 192, in update_spines
self['b'].data = np.array(([xmin, ymin], [xmax, ymin]))
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/frame.py", line 40, in data
self._world = self.transform.transform(self._data)
File "/usr/local/lib/python3.4/dist-packages/wcsaxes/transforms.py", line 166, in transform
world = self.wcs.wcs_pix2world(pixel_full, 1)
File "/usr/local/lib/python3.4/dist-packages/astropy/wcs/wcs.py", line 1329, in wcs_pix2world
'output', *args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/astropy/wcs/wcs.py", line 1231, in _array_converter
return _return_single_array(xy, origin)
File "/usr/local/lib/python3.4/dist-packages/astropy/wcs/wcs.py", line 1212, in _return_single_array
"of shape (N, {0})".format(self.naxis))
ValueError: When providing two arguments, the array must be of shape (N, 3)
清除存储数据
事件触发,因此您必须在清除之前将存储的cssClass从该数组传递到$localStorage.tableArray
。它通过以下方式与我合作:
1-将$ filter添加到控制器:
$scope.tablelist
2-在 app.controller('MainCtrl', function ($scope, $localStorage, $filter) {
之前添加以下代码:
$scope.getTable = function
编辑: 这是plnkr链接: https://plnkr.co/edit/x32vQIJO6wbzZjDa77WH?p=preview