繁体   English   中英

我可以<a>使用自动完成输入框的选定值</a>设置<a>标签</a>的href吗

[英]Can I set the href of <a> tag with the selected value of autocomplete input box

我想在ng-href链接中插入city.value 请帮助我,某人。

这是文本框

<input id="city" name="states" type="text"
       class="txt-dep-ret input-icon-depart country-autocomplete ui-autocomplete-input form-control"
       placeholder="Select Origin" allow-custom="false"  autocomplete="off">

这是ng-href的按钮链接

<a id="sbutton" target="_blank" class="btn btn-primary btn-lg"
   style="background-color: #E28F13; font-size: 14px"
   ng-href="@Url.Action("Booking", "home")?Rooms={{rooms}}&Destination={{city}} &DepartureDate={{departuredate}}&ReturnDate={{returndate}}&Adults1={{Adults1}}&Children1={{Children1}}&C1Age1={{C1Age1}}&C1Age2={{C1Age2}}&C1Age3={{C1Age3}}&C1Age4={{C1Age4}}&Adults2={{Adults2}}&Children2={{Children2}}&C2Age1={{C2Age1}}&C2Age2={{C2Age2}}&C2Age3={{C2Age3}}&C2Age4={{C2Age4}}&Adults3={{Adults3}}&Children3={{Children3}}&C3Age1={{C3Age1}}&C3Age2={{C3Age2}}&C3Age3={{C3Age3}}&C3Age4={{C3Age4}}" 
   onclick="validate(event);"> Search </a>

我想将目的地设置为city.value

您需要在文本框输入中设置ng-model

 var app = angular.module('myApp', []); app.controller('myCtrl', function($scope) { }); 
 <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script> <div ng-app="myApp" ng-controller="myCtrl"> <input id="city" name="states" type="text" class="txt-dep-ret input-icon-depart country-autocomplete ui-autocomplete-input form-control" placeholder="Select Origin" allow-custom="false" autocomplete="off" ng-model="hash"> <a ng-href="https://www.google.lk/{{hash}}">Search</a> </div> 

应该能够做到{{city.value}} 编辑:这是错误的,请参阅下面的我的评论或其他答案。

另外,您还需要转义围绕Booking和home的双引号,或将其更改为单引号。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM