$ http.jsonp filltext字符串中的连接

时间:2014-11-01 12:21:14

标签: javascript angularjs angularjs-http

您好我正在尝试对filltext.com服务器执行动态$ http请求。 代码:

<!DOCTYPE html>
<html lang="en" ng-app="App">
    <head>
        <meta carset="utf-8">
        <title>Test</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
    </head>

<body >
    <div class="container" ng-controller="theController">
        <div ng-repeat="person in people">
            <input type="text" ng-model="person.fname">
            <input type="text" ng-model="person.lname">


        </div>
    </div>


    <script>
    var app=angular.module('App', []);
    app.controller('theController', ['$scope','$http',function($scope,$http){
        $scope.getPeople=function(count){
            $http.jsonp("http://www.filltext.com/?callback=JSON_CALLBACK&rows="+count+"&fname={firstName}&lname={lastName}").
    success(function (data) {
        $scope.people = data;
    })
        };

        $scope.countSelection=10;
        $scope.getPeople($scope.contSelection);

    }]);

    </script>       

</body>
</html>

问题是当我试图将+ count +添加到$ http.jsonp字符串参数时我没有从filltext.com获取数据,但是当我静态写行= 5时它会生成数据 谢谢你的帮助:))

0 个答案:

没有答案