单击"添加"后尝试清除输入框,就像 本教程中的人员一样.
我使用这个简短的代码重新创建了错误,而没有使用API.
您还可以查看Plunker.
HTML
<input ng-model="contact.name" type="text">
<button ng-click="Add()">Add</button>
<ul ng-repeat="contact in contactList">
<li>{{ contact.name }}</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
JS
$scope.contactList = [
{name: 'cris'}, {name: 'vlad'}
;]
$scope.Add = function() {
$scope.contactList.push($scope.contact)
$scope.contact = ""
}
Run Code Online (Sandbox Code Playgroud)
Mis*_*lis 15
你没有contact
以正确的方式清理你的物体.在该Add()
功能中,更改:
$scope.contact = ""
Run Code Online (Sandbox Code Playgroud)
至:
$scope.contact = {};
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
33680 次 |
最近记录: |