Angularjs 如何使用ng存储来存储数据阵列?

Angularjs 如何使用ng存储来存储数据阵列?,angularjs,angular-ui-bootstrap,ng-storage,Angularjs,Angular Ui Bootstrap,Ng Storage,是我干的。当我点击按钮时,我正在按下该项,按钮颜色将变为红色,当我点击同一按钮时,按钮颜色将变为绿色 ` 我的问题是如何使用ng存储实现此功能。刷新页面时,推送的项目将保持不变。颜色将是不变的 <script> var app = angular.module('plunker', []); app.controller('MainCtrl', function($scope) { $scope.tablelist = [{"tablename":"t1"},{"tablename"

是我干的。当我点击按钮时,我正在按下该项,按钮颜色将变为红色,当我点击同一按钮时,按钮颜色将变为绿色

`

我的问题是如何使用ng存储实现此功能。刷新页面时,推送的项目将保持不变。颜色将是不变的

<script>
var app = angular.module('plunker', []);
app.controller('MainCtrl', function($scope) {
$scope.tablelist = [{"tablename":"t1"},{"tablename":"t2"}]
$scope.tableArray=[]
$scope.tableslist=[]
$scope.tableget=function(table){
     table.btnClass = table.btnClass == "btn-danger" ? "btn-success" : "btn-danger"
     var exists=false;
     angular.forEach($scope.tableArray, function (list,$index) {
        if ((list.tablename == table.tablename)) {
            console.log(list.tablename)
             console.log(table.tablename)
            exists=true;
            $scope.tableArray.splice($index,1)
            return false
        }
     });
    if(!exists){
    $scope.tableslist.push(table)
  $scope.tableArray=$scope.tableslist
  console.log($scope.tableArray)
   table.color="red"
    }
} 
 });

var app=angular.module('plunker',[]);
应用程序控制器('MainCtrl',函数($scope){
$scope.tablelist=[{“tablename”:“t1”},{“tablename”:“t2”}]
$scope.tableArray=[]
$scope.tableList=[]
$scope.tableget=函数(表){
table.btnClass=table.btnClass==“btn危险”?“btn成功”:“btn危险”
var=false;
angular.forEach($scope.tableArray,函数(list,$index){
if((list.tablename==table.tablename)){
console.log(list.tablename)
console.log(table.tablename)
存在=真;
$scope.tableArray.splice($index,1)
返回错误
}
});
如果(!存在){
$scope.tableList.push(表)
$scope.tableArray=$scope.tableList
log($scope.tableArray)
table.color=“红色”
}
} 
});
请帮我怎么做