<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<div ng-app="" ng-controller="cntryController">
<input list="testList" type="" ng-model="SelectedDoctor" ng-change="LoadSessionData(SelectedDoctor)" />
<datalist id="testList">
<option value="Dr.Test1" ng-selected="selected"></option>
<option value="Dr.Test2"></option>
<option value="Dr.Test2"></option>
</datalist>
</div>
控制器
function cntryController($scope) {
$scope.LoadSessionData = function(val) {
console.log(val);
};
}
检查此链接http://jsbin.com/jifibugeke/1/edit?html,js,控制台,输出 http://jsbin.com/jifibugeke/1/edit?html,js,console,output
上面提到了使用 angularjs 的数据列表示例代码和 URL,这里我的问题是我在文本框中输入的内容,在控制器中添加添加每个单词,在我的数据列表中的要求中,选定的详细信息仅显示在控制器中,
//here your html
<div ng-app="myapp1" ng-controller="cntryController">
<input list="testList" type="" ng-model="SelectedDoctor" ng-change="LoadSessionData(SelectedDoctor)" />
<datalist id="testList">
<option ng-repeat="x1 in names" value="{{x1.drname}}">
</datalist>
</div>
//here your script
<script>
var app=angular.module('myapp1',[]);
app.controller('cntryController',function ($scope) {
//data for ng-repeat
$scope.names=[{'drname':'Dr.Test1'},{'drname':'Dr.Test2'},{'drname':'Dr.Test3'}]
$scope.LoadSessionData = function(val) {
//console log
console.log(val);
}
});
</script>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)