我的angularJs代码没有得到文本框的值,我以前做过这个并且无法看到我做错了什么!
在html页面中,我有一个文本框和一个按钮:
<div class="form-group">
<label>Date</label>
<input type="text" ng-modal="items.appdate" placeholder="Appointment Date" class="form-control">
</div>
<button class="btn btn-sm btn-primary pull-right m-t-n-xs" ng-click="saveAppointment()"><strong>Create</strong></button>
并在控制器中:
$scope.items = {
appdate: ''
}
$scope.saveAppointment=function(){
console.log($scope.items);
}
但日志只是
对象{appdate:&#34;&#34;}
为什么它没有拿起文本框?
答案 0 :(得分:3)
你有一个错字。
是ng-model
而不是ng-modal
检查here以获取文档。
您的代码必须像这样
<input type="text" ng-model="items.appdate" placeholder="Appointment Date" class="form-control">
答案 1 :(得分:0)
用ng-model替换ng-modal。