gpt4 book ai didi

javascript - Angular : Texbox value not showing

转载 作者:行者123 更新时间:2023-11-30 12:29:45 25 4
gpt4 key购买 nike

在 agularjs Controller 中我正在创建变量

var search = [];
search.area = 'xyz';
$scope.search = search;

在html页面中

 <input type="text" name="area" class="form-control" data-ng-model="search.area" placeholder="Area">

因此,加载页面后,默认值不会在文本框中显示为“xyz”。

请指导!!

最佳答案

你的 Controller 有问题:-)您的代码运行良好

<div ng-app="myApp" ng-controller="MyCtrl"><input type="text" name="area" class="form-control" data-ng-model="search.area" placeholder="Area"/>

</div>
<script>
var myApp = angular.module('myApp',[]);
function MyCtrl($scope) {
var search = [];
search.area = 'xyz';
$scope.search = search;
}
</script>

fiddle :- http://jsfiddle.net/4rwnefnL/

关于javascript - Angular : Texbox value not showing,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28103358/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com