gpt4 book ai didi

javascript - Angular ngSubmit 不起作用

转载 作者:行者123 更新时间:2023-12-03 04:17:12 24 4
gpt4 key购买 nike

有以下代码:

<form data-ng-submit="ctrl.filter()" novalidate="true" class="search-filter ng-valid ng-dirty ng-valid-parse">
<fieldset>
<div class="search-filter-group">
<div class="search-field-group">
<div class="text-field">
<input type="text" placeholder="Type some text" data-ng-model="ctrl.searchString" class="ng-valid ng-touched ng-dirty ng-valid-parse">
<div data-ng-click="ctrl.resetFilter()" class="action-button reset-button">Reset</div>
</div>
</div>
<input type="submit" value="Find" data-ng-class="{disabled: !ctrl.canFilter()}" class="button">
</div>
</fieldset>
</form>

但是当我点击提交输入“ctrl.filter()”函数时不会被触发,但是如果我将 data-ng-click="ctrl.filter()" 添加到我的提交输入即可。有什么麻烦吗?

最佳答案

<div id="example" ng-app="StackM">
<div ng-controller="StackC as ctrl">
<form data-ng-submit="ctrl.filter()" novalidate="true" class="search-filter ng-valid ng-dirty ng-valid-parse">
<fieldset>
<div class="search-filter-group">
<div class="search-field-group">
<div class="text-field">
<input type="text" placeholder="Type some text" data-ng-model="ctrl.searchString" class="ng-valid ng-touched ng-dirty ng-valid-parse">
<div data-ng-click="ctrl.resetFilter()" class="action-button reset-button">Reset</div>
</div>
</div>
<input type="submit" value="Find" data-ng-class="{disabled: !ctrl.canFilter()}" class="button">
</div>
</fieldset>
</form>
</div>

<script>
angular.module("StackM", [])
.controller("StackC", function($scope){
this.filter = function(){
var a = this.searchString
debugger;
}

})

关于javascript - Angular ngSubmit 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44096991/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com