【问题标题】:Angularjs + nodejs + mysqlAngularjs + nodejs + mysql
【发布时间】:2014-08-22 21:53:05
【问题描述】:

在移动视图中出现问题,在 angularjs 中没有接收到数据.. 桌面视图工作得很好..什么是最好的解决方案 抱歉英语不好………………………………………………………………………… ..................................................... ......

PHP file

<body ng-app="app" ng-controller="fcontrol">


<div ng-repeat="person in people">
{{person.fname}}
{{person.lname}}
{{person.email}}
{{person.address}}

</div>

<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.20/angular.min.js"></script>
<script src="js/control.js"></script>

</body>



Angularjs(control.js)

angular.module("app" , []);

function fcontrol($scope, $http) {

    $http.get("http://localhost:8000/users")
      .success(function(data) {
       $scope.people = data;

     })


}



Nodejs

app.get('/users', function(req, res) {

      var s = 'SELECT * FROM tbl_user order by fname';

      dbconn.query(s, function(err, rows, fields) {
         var row = [];

         if (err) throw err;
           //console.log(rows)
           res.send(rows);
           res.end();
      });


  });

【问题讨论】:

    标签: mysql node.js angularjs


    【解决方案1】:

    尝试将 Angular JS 代码中的 http get url 更改为您的 IP:8000/users。(将 localhost 替换为您的系统 IP)。 还要确保您的手机和 PC 应连接到同一网络。(如果您的 IP 不公开)

    Angularjs(control.js)
    
    angular.module("app" , []);
    
    function fcontrol($scope, $http) {
    
        $http.get("http://<your ip>:8000/users")
          .success(function(data) {
           $scope.people = data;
    
         })
    
    
    }
    

    【讨论】:

    • 感谢您的回复...我忘了 angularjs 是客户端..再次感谢
    猜你喜欢
    • 2017-04-02
    • 2017-11-26
    • 2014-06-30
    • 2015-10-14
    • 2016-07-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-17
    • 1970-01-01
    相关资源
    最近更新 更多