【发布时间】:2015-03-19 16:03:38
【问题描述】:
我正在使用 Angular,并且正在使用 $resource 向 MVC 中的控制器发出请求。我遇到了一个问题,它在 IE11 中不起作用。适用于 chrome 和 firefox。
我有一个 homeController.js,它带有这个 $scope,当它到达 div 时会在 ng-init 上调用它
$scope.getUserShortcuts = function () {
$scope.shortcuts = usersService.getUserShortcuts(11);
}
这调用了我的 userService.js
(function () {
"use strict";
var myAppModule = angular.module('myApp');
myAppModule.factory('usersService', ['$resource', function ($resource) {
console.log("load it");
// user = controller, getusershortcuts = method, :userId = param
var userShortcuts = $resource('/user/shortcuts/11', null,
{
'get': { method: 'GET', isArray:true }
});
getUserShortcuts: function (userId) {
alert("test");
return userShortcuts.query(userId);
}
};
}]);
})();
我的警报被调用,但 IE11 甚至没有尝试进行 GET。
这是我的错误:
TypeError: Object.keys: argument is not an Object
at extend (http://localhost:45669/Scripts/angular.js:412:7)
at Resource[name] (http://localhost:45669/Scripts/angular-resource.js:574:13)
at getUserShortcuts (http://localhost:45669/Scripts/app/services/userService.js:94:17)
at $scope.getUserShortcuts (http://localhost:45669/Scripts/app/controllers/homeController.js:171:21)
at $parseFunctionCall (http://localhost:45669/Scripts/angular.js:12331:7)
at Scope.prototype.$eval (http://localhost:45669/Scripts/angular.js:14383:9)
at pre (http://localhost:45669/Scripts/angular.js:23851:9)
at invokeLinkFn (http://localhost:45669/Scripts/angular.js:8213:9)
at nodeLinkFn (http://localhost:45669/Scripts/angular.js:7701:11)
at compositeLinkFn (http://localhost:45669/Scripts/angular.js:7075:13) <div class="row" ng-init="getUserShortcuts(11)">
value= undefined
有谁知道问题出在哪里?
【问题讨论】:
-
你有这方面的 plnkr/fiddle 吗?
标签: angularjs get internet-explorer-11