Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/376.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何打印Json结果以在angular js中查看_Javascript_Php_Jquery_Json_Angularjs - Fatal编程技术网

Javascript 如何打印Json结果以在angular js中查看

Javascript 如何打印Json结果以在angular js中查看,javascript,php,jquery,json,angularjs,Javascript,Php,Jquery,Json,Angularjs,您好,我是angular js新手,我需要一些帮助,当用户单击edit it redirect to edit form时,我在angular js中有一个编辑表单,但我遇到了一些问题,我的json结果如下所示: [{"0":"3", "1":"The only people for me are the mad ones", "2":"“The only people for me are the mad ones, the ones who are mad t

您好,我是angular js新手,我需要一些帮助,当用户单击edit it redirect to edit form时,我在angular js中有一个编辑表单,但我遇到了一些问题,我的json结果如下所示:

    [{"0":"3",
      "1":"The only people for me are the mad ones",
      "2":"“The only people for me are the mad ones, the ones who are mad to live, mad to talk, mad to be saved, desirous of everything at the same time, the ones who never yawn or say a commonplace thing, but burn, burn, burn like fabulous yellow roman candles exploding like spiders across the stars.”",
      "3":"2015-05-08 13:01:58",
      "id":"3","title":"The only people for me are the mad ones",
      "description":"“The only people for me are the mad ones, the ones who are mad to live, mad to talk, mad to be saved, desirous of everything at the same time, the ones who never yawn or say a commonplace thing, but burn, burn, burn like fabulous yellow roman candles exploding like spiders across the stars.”",
      "created_on":"2015-05-08 13:01:58"
}]
我想知道如何在视图中打印我的标题、描述

这是我的控制器文件:从数据库中获取数据的位置:

 var myApp = angular.module("blogapp",[]);

  myApp.config(['$routeProvider',function($routeProvider){

    $routeProvider
      .when('/home',{
        templateUrl:'home.html',
        controller:'blogcontroller'
      })
      .when('/list',{
        templateUrl:'list.html',
        controller:'blogcontroller'

      })
      .when('/add',{

        templateUrl:'add.html',
        controller:'addcontroller'
      })
      .when('/edit/:Blogid',{

        templateUrl:'edit.html',
        controller:'editcontroller'
      })
      .otherwise({
        redirectTo:'/home'
      });

  }]);


myApp.controller('blogcontroller',function ($scope,$http){

    $http({method: 'GET' , url: 'getallblog.php'}).success(function(data){
      $scope.allblog = data;

      console.log(data);
    });

// DELETE blog HERE 
 $scope.removeRow= function(id){



    $http.post("removeblog.php",{'id' : id}).success(function(data,status,headers,config){
      window.location='index.html';
      console.log("Deleted Successfully");

  });
  };

// delete blog code ends here


  });


myApp.controller('addcontroller',function ($scope,$http){





  /// New Post Here
    $scope.new_post =function(){



    $http.post("addblog.php" ,{'title' : $scope.title ,'description' : $scope.description }).success(function(data,status,headers,config){
      window.location='index.html';
      console.log("inserted Successfully");
    });
  };



  // New Post ends Here

});

myApp.controller('editcontroller',function ($scope,$http,$routeParams){

     $scope.Blogid = $routeParams.Blogid;

     $http.post("getblog.php",{'id' : $scope.Blogid}).success(function(data){
      $scope.editit = data;  /// here i get the resuly  want to pass it t view

      console.log(data);

  });


});
我的编辑html表单:edit.html

    <!-- Page Content -->
    <div class="container">

        <div class="row">

            <!-- Blog Entries Column -->
            <div class="col-md-6">

                <h1 class="page-header">
                   Angular Blog 

                </h1>


               <div >

        <form class="form-signin">


        <h2 class="form-signin-heading">Modify // want to print title here </h2>
        <div class="row">
        <div class="col-md-12">
        <label for="posttitle" class="sr-only">Email address</label>
        <input type="text" id="posttitle" class="form-control" ng-model="{{title}}"  required="" value=""><br>
        <span>Title : // want to print title here</span>
        </div>
        </div>
        <br>
        <div class="row">
        <div class="col-md-12">
        <label for="postdetails" class="sr-only">Password</label>
        <textarea id="postdetails" class="form-control" ng-model="description" required=""></textarea>
        <br>
        <span>Blog Description: // want to print description here</span>
        </div>
       </div>
       <br>
       <div class="row">
       <div class="col-md-3"></div>
       <div class="col-md-6">
        <button class="btn btn-lg btn-primary btn-block" type="button" ng-click="edit_post()" name="editblog">Modify Now</button>
        </div>
              <div class="col-md-3"></div>
        </div>

      </form>

      </div>

            </div>
             <div class="col-md-2"></div>
            <!-- Blog Sidebar Widgets Column -->
             <div ng-include="'includes/sidebar.html'">                    
</div>

        </div>
        <!-- /.row -->



    </div>
    <!-- /.container -->

角度博客
修改//要在此处打印标题吗
电子邮件地址

Title://要在此处打印标题吗
密码
Blog Description://要在此处打印说明吗
立即修改
类似这样的内容:

        <span>Blog Description: {{allblog.description}}</span>
Blog描述:{{allblog.Description}

博客描述:

如果您的allblog是一个数组,请使用allblog[0]

打印标题,首先需要在JS中替换这一行:

  $scope.allblog = data;

现在,您可以用HTML编写以下语句:

{{allblog.title}}

为什么需要
ngbindhtml
?在计算页面之前,在页面中不显示{{{allblog.description}}。ng bind html在插入操作完成后才会显示。请将其添加到html中,并告诉我结果如何?博客:{{allblog | json}}还有一件事我想在文本框中打印标题进行编辑,它不会在文本框中显示任何内容
  $scope.allblog = data[0];
{{allblog.title}}