gpt4 book ai didi

javascript - 如何使用 Angularjs 将 JSON 文件从本地计算机加载到变量?

转载 作者:行者123 更新时间:2023-12-01 03:39:03 24 4
gpt4 key购买 nike

我正在添加用于将名为 view.json 的外部 json 文件添加到我的controller.js 中的语法,但它没有提供所需的输出,或者我在控制台中没有收到任何响应。

$.require(['api-data/actions/product/view.json'], function(data) {
$scope.data=data;console.log(data);

查看.json

{ 

'key':'{"name":"data[key]","id":"input_token","placeholder":"API token","description":"Enter the api_token","value":"","type":"text","required":"required"}',

'filter': {

'name': '{"name":"data[filter][name]","id":"input_name","placeholder":"not mandatory","description":"leave blank ","value":"","type":"text","required":""}',
},

'extra': {
'pageJump': '{"name":"data[extra][pagejump]","placeholder":"First Name","description":"Enter page number[0,1,-1]","value":"0","type":"text","required":"required"}'
}

最佳答案

你可以这样做:

$http.get('path/file.json').success(function(data) {
$scope.jsonData = data;

});

关于javascript - 如何使用 Angularjs 将 JSON 文件从本地计算机加载到变量?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44016545/

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