admin管理员组文章数量:1430050
The following code works for allowing multiple inputs in a list:
<ion-content>
<ion-list>
<ion-item ng-repeat="player in players">
<ion-label>Player {{$index+1}}</ion-label>
<input type="text" ng-model="player.name"></input>
</ion-item>
</ion-list>
</ion-content>
And in js
angular.module('ionicApp', ['ionic'])
.controller('MyCtrl', function($scope) {
$scope.players = [{name:'Bart'},{name:'Lisa'}];
});
Each item in the list can be clicked on and a string entered. But when I replace <input>
with <ion-input>
(as I think I'm supposed to) the items no longer allow string entry, they just flash when clicked. How can that be fixed?
The following code works for allowing multiple inputs in a list:
<ion-content>
<ion-list>
<ion-item ng-repeat="player in players">
<ion-label>Player {{$index+1}}</ion-label>
<input type="text" ng-model="player.name"></input>
</ion-item>
</ion-list>
</ion-content>
And in js
angular.module('ionicApp', ['ionic'])
.controller('MyCtrl', function($scope) {
$scope.players = [{name:'Bart'},{name:'Lisa'}];
});
Each item in the list can be clicked on and a string entered. But when I replace <input>
with <ion-input>
(as I think I'm supposed to) the items no longer allow string entry, they just flash when clicked. How can that be fixed?
1 Answer
Reset to default 6There are 2 versions of ionic available, which are ionic v1
and ionic v2
. Looking from you controller code, I believe that you are using ionic v1
but you are looking on ionic v2
documentation for implementation.
Do note that ion-label
and ion-input
is a ponent introduced in ionic v2
. Therefore, it perfectly make sense that ion-input
does not work in your ionic v1
code.
The standard approach of implementing label and input in ionic v1
is as follow, which you can find in Ionic v1 official documentation
<div class="list">
<label class="item item-input">
<input type="text" placeholder="First Name">
</label>
<label class="item item-input">
<input type="text" placeholder="Last Name">
</label>
<label class="item item-input">
<textarea placeholder="Comments"></textarea>
</label>
</div>
本文标签: javascriptioninput not working but input doesStack Overflow
版权声明:本文标题:javascript - ion-input not working but input does - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745550107a2662900.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论