i need one help.I need to fetch data from my data.json file using the unique id.I am explaining my code below.

我需要一个帮助。我需要使用唯一的id从我的data.json文件中获取数据。我正在解释下面的代码。

 $scope.editProfileData=function(){
         var editid={'id':2};
         $http({
         method: 'POST',
         url: 'profile.json',
         data:editid
     }).then(function successCallback(response){

     },function errorCallback(response) {

     });

     }

Here i need when the condition (id==2) will match in json file it will fetch those specific data.Please help me.

这里我需要当条件(id == 2)在json文件中匹配时它将获取那些特定数据。请帮助我。

2 个解决方案

#1


2

Try it:

尝试一下:

//...
}).then(function successCallback(response){
    var i, l = response.data.length;
    for(i = 0; i < l; i++){
        if( response.data[i].id == 2){
            fetch( response.data[i]); // your fetch code here
            break;
        }
    }
}).
//...

更多相关文章

  1. javaScript怎么实现双向数据绑定
  2. 如何从一个节点生成exe文件。js应用?
  3. 使用Directive通过AngularJS使用指令和数据绑定来注入HTML
  4. 一旦db通过Node.js发生更新,就立即推送数据
  5. ng- repeat显示的行等于no属性,甚至不显示html视图上的数据
  6. 将数据从AJAX请求序列化到PHP
  7. 在Servlet和HTML页面之间处理函数调用和数据传输的最佳方法是什
  8. 使用HTML文件中的React调用.js文件中的Javascript函数
  9. 访问D3的var格式数据

随机推荐

  1. Netty编解码框架分析
  2. java关键字系列(5)super
  3. Ubuntu xx中编译Android(安卓)xx中软件安
  4. SpringBoot系列(1)基础入门
  5. 设计模式之模板方法模式
  6. SpringBoot系列(2)整合MongoDB实现增删改查
  7. 设计模式之桥接模式
  8. java集合系列(5)LinkedList
  9. 面试必问:String类型为什么设计成不可变的
  10. 设计模式之组合模式