【问题标题】:Ionic framework and angularjs form creation离子框架和angularjs表单创建
【发布时间】:2016-09-30 05:21:57
【问题描述】:

我在 ionic 框架和 Angular-JS 的帮助下创建了一个注册表单。填写表单详细信息后,从一个输入字段到另一个输入字段,当我按下回车按钮时,我需要光标移动到下一个字段。我试过但没有得到它。帮我做那个输出?

【问题讨论】:

  • 谁能告诉我下面这一行的含义 cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

标签: angularjs ionic-framework


【解决方案1】:

您需要自定义指令,此代码可能对您有所帮助

.directive('focus', function() {
  return {
    restrict: 'A',
    link: function($scope,elem,attrs) {

      elem.bind('keydown', function(e) {
        var code = e.keyCode || e.which;
        if (code === 13) {
          e.preventDefault();
          elem.next().focus();
        }
      });
    }
  }
});

【讨论】:

  • 如果添加了该指令,是否需要对 index.html 文件进行任何更改
  • 指令中的“焦点”是什么?
  • 你能再帮我一次吗?
  • 你需要在你的html页面中使用'focus'作为属性,你需要将指令js文件导入到
【解决方案2】:

能否请您输入表单的 html 代码。

对于输入,您可以添加“必需”。

例如:

<ion-content>
<form class="list" name="login" ng-submit="login.$valid && login(user)">

        <label class="item item-input item-floating-label">
        <span class="input-label">USERNAME</span>
        <input type="text" name="userName" ng-model="user.userName" placeholder="name" required>
      </label>
          <label class="item item-input item-floating-label">
        <span class="input-label">PASSWORD:</span>
        <input type="text" name="userPass" ng-model="user.userPass"  placeholder="password" required>
      </label>  

          <button class="button  button-assertive" type="submit">LOGIN</button> 

    </form>
</ion-content>

【讨论】:

  • 它在 ionic 但不在 html 中
  • 我们有上面的代码
  • 以上与我的离子代码类似,但没有得到所需的输出
  • 你能编辑你上面的问题并添加你的html代码吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-06-24
  • 2019-09-17
  • 1970-01-01
  • 1970-01-01
  • 2015-01-13
  • 2015-08-11
  • 1970-01-01
相关资源
最近更新 更多