重点是我想通过一些下拉菜单和少量输入(暂时)将一些数据保存到localstorage中。我可以从输入中获取所有值,我在console.log中看到它。我想将输入保存到localstorage作为对象(单击按钮Spremi),并在更改选项后再单击以将另一个对象保存到lcoalsotrage等。
browse.html
<ion-view view-title="Browse">
<ion-content>
<select id="vrstaribe" ng-model="selekt" ng-options="r as r for r in ribe" selected>
<option value="">Vrsta ribe</option>
</select>
<label class="item item-input">
<input id="tezina" type="number" placeholder="Tezina">
</label>
<label class="item item-input">
<input id="mamac" type="text" placeholder="Mamac">
</label>
<button class="button button-positive" ng-click="spremi()">Spremi</button>
</ion-content>
</ion-view>
contollers.js
.controller('SpremiCtrl', function($scope) {
var ulov = {vrstaribe: '', tezina: '', mamac: '' };
var popisulova = [];
$scope.ribe = ["Saran", "Stuka", "Som"];
$scope.spremi = function() {
var vr = document.getElementById('vrstaribe');
var rib = vr.options[vr.selectedIndex].text;
var tez = document.getElementById('tezina').value;
var mam = document.getElementById('mamac').value;
console.log("Riba : " + rib + '\n' + "Težina : " + tez + '\n' + "Mamac : " + mam);
ulov.vrstaribe = rib;
ulov.tezina = tez;
ulov.mamac = mam;
popisulova.push(ulov);
console.log(ulov);
localStorage.setItem('ulov', JSON.stringify(ulov));
var vrati = localStorage.getItem('ulov');
//console.log('Ulov: ', JSON.parse(vrati));
console.log(ulov);
}
})
答案 0 :(得分:0)
这将解决您的问题,但您还有很多其他问题,并且您没有采用角度方式编码&#34;。
Public Function IsAllCheckBoxesChecked() As Boolean
Dim isAllChecked As Boolean = True
For Each chk As CheckBox In Me.Controls.Cast(Of CheckBox)
If checkbox.Equals(Me.chkAll) = True Then Continue For
If checkBox.Checked = false Then
isAllChecked = false
Exit For
End If
Next
Return isAllChecked
End Function
答案 1 :(得分:0)
您可以使用ngStorage
,请参阅https://github.com/gsklee/ngStorage
angular.module('app', [
'ngStorage'
]).controller('Ctrl', function($scope, $localStorage, $sessionStorage){
// put your code here!
});