我已经尝试将html5 required属性用于我的复选框组,但我找不到用ng-form实现它的好方法.
选中复选框时,我希望将该input-element的值推送到值数组.
角度所需的验证器似乎观察与输入元素关联的ng模型,但是如何将多个复选框链接到同一模型并使用输入字段的值更新它的值?
现在,实现就像这个小提琴.
<div ng-controller="myCtrl">
<ng-form name="myForm">
<span ng-repeat="choice in choices">
<label class="checkbox" for="{{choice.id}}">
<input type="checkbox" required="required" value="{{choice.id}}" ng-click="updateQuestionValue(choice)" ng-model="choice.checked" name="group-one" id="{{choice.id}}" />
{{choice.label}}
</label>
</span>
<input type="submit" value="Send" ng-click="submitSurvey(survey)" ng-disabled="myForm.$invalid" />
</ng-form>
</div>?
Run Code Online (Sandbox Code Playgroud)
updateQuestionValue函数处理从值数组中添加或删除,但每个复选框都有自己的模型,这就是为什么需要检查每个复选框以使表单有效.
我已经让它在一组单选按钮上工作,但它们都在相同的模型上工作,因为只能选择一个.
我正在尝试使用gradle作为构建工具来构建Cordova项目.在Cordova项目中,我有自己的插件,需要Java 1.7.
在Cordova附带的build.gradle中,java版本是1.6.的build.gradle:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
}
}
Run Code Online (Sandbox Code Playgroud)
build.gradle有一个很大的警告,说它是一个不应该编辑的生成文件,自定义gradle构建步骤的方法是 - 据我所知 - 创建build-extras.gradle文件.
我创建了一个build-extras.gradle文件,并尝试了以下内容:
android {
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
Run Code Online (Sandbox Code Playgroud)
但它似乎没有用.我构建项目时仍然出错.
错误:
> strings in switch are not supported in -source 1.6
> switch (action) {
> ^ (use -source 7 or higher to enable strings in switch)
Run Code Online (Sandbox Code Playgroud)
有人可以帮我弄清楚如何设置gradle来使这项工作?