【发布时间】:2015-05-18 00:13:13
【问题描述】:
在 safari 上,angular 抛出一个奇怪的错误请求的键值不是对象。当我调用下面的函数时。它在 chrome 和 firefox 上运行良好,但在 safari 上却不是那么好。我什至调用了 console.log 来查看错误在哪里,以及 $scope.id 是否返回一个值以从该 ID 中提取所有其他数据......测试了一些东西无济于事。
app.controller('ViewOneArtist', function($scope, $http, $resource, artistesUrl, baseUrl, $stateParams) {
$scope.artistesItemsResource = $resource(baseUrl + artistesUrl + $stateParams.id, {id: "@id"},
{ create : { method: "POST"}, save: { method: "PUT"}}
);
$scope.id = $stateParams.id;
console.log($scope.id);
console.log("got to here...before listOneArtiste");
$scope.listOneArtiste = function(id) {
$scope.artistesItem = $scope.artistesItemsResource.get(id);
};
console.log("got to here...after declared listOneArtiste");
$scope.listOneArtiste($stateParams.id);
console.log("got to here...after calling listOneArtiste");
});
Console.log 从 $scope.id 或 $stateParams.id 返回一个值(例如:43),但是当我调用函数 listOneArtist() 时,它会抛出上述错误。有什么建议吗?
【问题讨论】:
标签: javascript angularjs safari