AngularJS 验证不适用于人员选择器指令

AngularJS Valdiation not working with People Picker directive

我正在使用以下指令,因此我可以在我的表单中使用 SharePoint 客户端人员选择器:

https://github.com/jasonvenema/sharepoint-angular-peoplepicker

但是,使用它会导致我的表单验证失败,因为我的按钮永远不会退出禁用状态。如果我删除该字段,验证有效,但我需要该字段。

这是我的按钮:

<button type="button" data-ng-disabled="myForm.$invalid" data-ng-click="save()" class="btn btn-default form-control">SAVE ONLY</button>

这是我正在使用的指令:

<sp-people-picker name="CC" id="CC" ng-model="vm.cc" min-entries="1" max-entries="20" allow-duplicates="false" show-login="false" show-title="true" min-characters="2" app-web-url="$scope.spAppWebUrl" />

为什么这个由指令控制的字段导致验证失败的任何线索,因为我的按钮永远不会变成 "enabled"?请注意,人员选择器不是必需的。好像 Angular 无法 "see" 字段来测试其有效性。

更新: 如果我将字段设置为 ng-required="false" 我的按钮将启用...除非我从人员选择器中删除值,在这会导致它返回到禁用状态,即使这个字段不是必需的!

这个问题已经解决,作为删除的onclick,我现在将模型重置为空。注意,由于是数组,所以格式如下:

$scope.vm.cc = [];