Angular js输入按键以转到下一页

时间:2014-10-16 10:42:15

标签: javascript angularjs web hybrid-mobile-app

我是Angular JS的新手,我目前正在尝试制作混合网络应用。我需要使用某种按键功能,当我点击输入标签上的输入时,它会进入下一页。到目前为止,我有以下内容:

 <label class="item item-input" style="width: 80%; margin:0 auto;">
    <input ng-model="name" type="text" placeholder="Enter your name"> </input>
  </label>    

2 个答案:

答案 0 :(得分:0)

您可以使用ng-keypress指令。 https://docs.angularjs.org/api/ng/directive/ngKeypress

因此,在input上添加ng-keypress="redirectMe($event)"

在你的控制器中,

$scope.redirectMe = function(evt){
    if (evt.which === 13) {  $location.path( "/yournextpage" );  }
}

答案 1 :(得分:0)

您可以使用指令

HTML:

<button ng-enter="doAction(namePage)" ></button>

Github存储库https://gist.github.com/EpokK/5884263