我需要在我的下拉菜单中存储ngchange以保存到localstorage,因此当有人关闭应用时,仍然保存更改。现在一切正常,但当应用程序重新加载时,用户必须再次进行选择。我如何使它起作用?如何在本地存储中保存ngChange
下面是HTML:
<select ng-model="item" ng-options="category.title for category in categories | filter: 234 | filter: {title: '!Federal'} "
ng-change="changedValue(item)" style="text-align: left;">
<option value="" selected="selected">Choose a State</option>
</select>
这里是JavaScript:
$scope.changedValue = function(item) {
$scope.categories.push(item.id);
console.log(item.id);
$localStorage.id = item.id;
console.log($scope.categories);
$scope.categories = $localStorage.categories;
$http.get('http://mywebsite.com/api/get_category_posts/?id=' + item.id).then(
function(data){
$scope.category_posts = data.data.posts;