How to trigger ng-change in directive test in AngularJS

后端 未结 5 1070
情歌与酒
情歌与酒 2021-01-01 15:13

I have the following AngularJS directive that creates an input element. Input has ng-change attribute that runs doIt() function. In my

5条回答
  •  情深已故
    2021-01-01 15:51

    simple and it works in your unit test env:

    spyOn(self, 'updateTransactionPrice');
    
    
    var el = compile('
    ')(scope); el.find('input').triggerHandler('change'); expect(self.updateTransactionPrice).toHaveBeenCalled();

提交回复
热议问题