有以下代码:
<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()"
添加到我的提交输入中,它就可以工作。有什么麻烦?
答案 0 :(得分:1)
<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;
}
})