不能在HTTP插入一个字符串获得角的要求 [英] Can not insert a string in a http get request in Angular

查看:180
本文介绍了不能在HTTP插入一个字符串获得角的要求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在输入字段特定的ID将被输入并保存在 SEARCHTEXT

In the input field specific id will be typed and saved inside searchText :

<form class="input-group" ng-submit="getMainData()">
  <input type="text" class="form-control" ng-model="searchText"  placeholder=" Type KvK-nummer and Press Enter" id="typehead">
</form>

和时preSS进入它将从控制器获得此功能

and when press enter it will get this function from the controller

$scope.getMainData = function(){    
 $http.get("http://localhost:8091/odata/dll-poc-dv/Account(':searchText')")
        .success(function(data){
            $scope.allData = data;
            $scope.getData = $scope.allData.d.results;
        });
    };

我想实现的是在输入输入 SEARCHTEXT 来为括号内的参数传递:获取的相关数据('SEARCHTEXT')。用于获取数据一个有效的URL看起来像这样:的http://本地主机:8091 / ODATA / DLL-POC-DV /账户('41 -125061-0000')

What I want to achieve is the searchText typed in the input to be passed as parameter inside the brackets (':searchText') of get the relevant data. A valid URL for getting the data looks like this: http://localhost:8091/odata/dll-poc-dv/Account('41-125061-0000')

推荐答案

使用 + 运营商的变数串联。此外,使用 $ scope.searchText

Use + operator for concatenation of variables. Also, use $scope.searchText.

$http.get("http://localhost:8091/odata/dll-poc-dv/Account('" + $scope.searchText + "')")

这篇关于不能在HTTP插入一个字符串获得角的要求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆