您好我正在努力找出为什么我的指令调用ngChange函数这么慢。没有模板,它的工作速度超快。
这是我的Html 指令模板
<input type="search" class="search_input artist-job-search-input"
placeholder="Search jobs by profession, musical work, role or institution"
ng-model="$ctrl.artistSearchModel"
ng-change="$ctrl.searchArtistJob()"
ng-model-options="{debounce: 500}" select-on-click
style="max-width: 55.9vw;"/>
这是 directive.js
app.directive('jobsSearch', function () {
return {
restrict: 'EA',
scope: {
'artistSearchModel': "=",
'showDropdown': "=",
'operaticRoleSearchResult': "=",
'viewAllJobs': "&",
'musicalWorkSearchResult': "=",
'institutionSearchResult': "=",
'changeTypeOfFilter': "&",
// 'searchFilterOne': "=",
// 'searchFilterTwo': "=",
// 'searchFilterThree': "=",
// 'searchFilterFour': "=",
// 'searchFilterFive': "=",
'searchArtistJob': "&",
'placeOfSearch':"@placeOfSearch",
'artistFilterSearch':'='
},
controller: function () { },
controllerAs: '$ctrl',
bindToController: true,
templateUrl: '/views/profile/directives/job_search.html'
};
});
这就是我调用指令Directive call
<jobs-search artist-search-model="jobDashboard.artistSearchModel"
search-artist-job="jobDashboard.searchArtistJob()"
show-dropdown="jobDashboard.showDropdown"
operatic-role-Search-result="jobDashboard.operaticRoleSearchResult"
view-all-jobs="jobDashboard.viewAllJobs(paramsJobs)"
musical-work-search-result="jobDashboard.musicalWorkSearchResult"
institution-search-result="jobDashboard.institutionSearchResult"
change-type-of-filter="jobDashboard.changeArtistJobFilter(params)"
place-of-search="Jobs"
artist-filter-search="jobDashboard.artistFilter"
答案 0 :(得分:0)
以下代码:
ng-model-options="{debounce: 500}"
告诉角度在完成打字后经过500毫秒后才识别出变化。这是你所指的dealy吗?