javascript - ion-input not working but input does - Stack Overflow

The following code works for allowing multiple inputs in a list:<ion-content><ion-list><

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?

Share Improve this question asked Nov 11, 2016 at 16:29 Sideshow BobSideshow Bob 4,7166 gold badges46 silver badges81 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

There 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>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745550107a4632534.html

相关推荐

  • javascript - ion-input not working but input does - Stack Overflow

    The following code works for allowing multiple inputs in a list:<ion-content><ion-list><

    20小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信