angularjs: passing filtered array to directive

后端 未结 1 1000
南旧
南旧 2021-01-13 22:00

I\'m looking for a way to pass a filtered array to a directive:

I\'ve tried the following:



        
相关标签:
1条回答
  • 2021-01-13 22:52

    Your both questions are related to each other.

    You can apply filter on on ng-model, but you should not do that. Because it will give you error you are facing in your second question.

    When you pass filter job to your directive, angular will place a watch on your jobs variable. So when jobs gets assigned in directive watch get called, which will trigger filter again, and this will goes on until maximum digest cycle reached by angular.

    To avoid this situation, you can create a filter method and pass that method in ng-model. This way you can avoid both copy creation and maximum digest cycle error.

    0 讨论(0)
提交回复
热议问题