gpt4 book ai didi

angularjs - 是否可以在 angularjs 模拟中使用通配符

转载 作者:行者123 更新时间:2023-12-04 06:04:05 25 4
gpt4 key购买 nike

是否可以在 Angular 模拟中使用通配符?例如:

$httpBackend.when('GET', '/api/checklists/*').respond({ userId: 'userX' }, { 'A-Token': 'xxx' });

而不是:
$httpBackend.when('GET', '/api/checklists/123').respond({ userId: 'userX' }, { 'A-Token': 'xxx' });

最佳答案

documentation建议它采用正则表达式,因此您可以执行以下操作:

$httpBackend.when('GET', /\/api\/checklists\/[1-9][0-9]*/)

这将需要匹配一个长度至少为 1 的整数 ID,而不是从零开始。当然,这只是一个例子。创建您自己的正则表达式来匹配。

关于angularjs - 是否可以在 angularjs 模拟中使用通配符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18618532/

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