gpt4 book ai didi

angularjs - 引用错误 : isUndefined is not defined in angular-local-storage

转载 作者:行者123 更新时间:2023-12-03 08:07:56 34 4
gpt4 key购买 nike

我正在使用 visual studio cordova、angular js 和 ionic 框架开发 html 5 移动应用程序。在那里,我需要将一些值保存到 localStorage。我关注了一些文章,但是在将值保存到本地存储时出现错误抛出。

<!doctype html>
<html ng-app="myApp">
<head> <title>Test app</title></head>
<body ng-app="myApp" ng-controller="MainCtrl">
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script src="angular-local-storage.js"></script>
<script src="http://code.ionicframework.com/1.0.0/js/ionic.bundle.js"></script>

<script>
var myApp = angular.module('myApp', ['ionic', 'LocalStorageModule']);

myApp.controller('MainCtrl', ['$scope', 'localStorageService', function ($scope, localStorageService) {

$scope.test = function () {
var storageType = localStorageService.getStorageType();
console.log(storageType);
localStorageService.set('test', 'val');
}
}]);
</script>
<div>
<input type="button" ng-click="test()" value="add new">
</div>
</body>
</html>

它抛出 ReferenceError: isUndefined is not defined at Object.addToLocalStorage

有什么想法吗??

最佳答案

这是一个正在处理您的应用程序的 plunker plnkr

var myApp = angular.module('myApp', ['ionic' ,'LocalStorageModule']).config(function(localStorageServiceProvider) {
localStorageServiceProvider
.setPrefix('cars')
.setStorageType('localStorage')
.setNotify(false, false);
}).controller('MainCtrl', ['$scope', 'localStorageService', function ($scope, localStorageService) {

$scope.test = function () {
var storageType = localStorageService.getStorageType();
console.log(storageType);
localStorageService.set('test', 'val');
}
}]);

关于angularjs - 引用错误 : isUndefined is not defined in angular-local-storage,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30381799/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com