我做了以下指令:
.directive('checkValueTypeArray', function () {
return {
restrict: 'A',
require: 'ngModel',
scope: {
typeElement: '=',
typeValue: '='
},
link: function (scope, element, attrs, ngModel) {
var type_value = scope.typeValue;
ngModel.$validators.required = function (v) {
switch (type_value) {
case "integer":
status = isInt(v);
break;
case "string":
status = isNaN(v);
break;
case "object":
status = true;
break;
case "array":
case "array_objects":
status = true;
break;
case "boolean":
status = (v === "true" || v === "false");
break;
case "float":
status = isNumeric(v);
break;
case "vector2":
status = (v.length === 2);
break;
case "vector3":
status = (v.length === 3);
break;
}
return status;
};
}
};
})
并将此指令称为:
<input
ng-required="true"
check-value-type-array
type-value="node.type_value"
type-element="node.type"
ng-value="item"
class="form-control"
ng-change="changeArrayValue(inputValue, $index, node, $parent.$index)"
ng-model="inputValue" type="text"
placeholder="Value ($$node.type_value$$)"
>
问题是如果status
为false,则不输入字段错误(颜色)。
所以,它对我不起作用。当我在DOM Chrome中看到输入时,我看到了孤立的模型。
答案 0 :(得分:0)
我假设您需要添加df = df.groupby(s).agg({'sentences':','.join, 'category':'first'}).reset_index(drop=True)
print (df)
category sentences
0 Data1 String1,String2,String3
1 Data2 String1,String4
2 Data2 String1,String6,String7
3 Data3 String1,String8,String9
:
查看angular.js源代码中的ngRequired指令:
$observe