Angularjs 为什么选择值不使用角度显示?
我正在使用angular js。我不知道为什么选择值或选择选项不显示。。 这是普朗克 问题步骤:运行应用程序并更改下拉值,它将不会显示。但当您按下按钮,然后更改下拉值时,它将显示。为什么Angularjs 为什么选择值不使用角度显示?,angularjs,angularjs-directive,angular-schema-form,Angularjs,Angularjs Directive,Angular Schema Form,我正在使用angular js。我不知道为什么选择值或选择选项不显示。。 这是普朗克 问题步骤:运行应用程序并更改下拉值,它将不会显示。但当您按下按钮,然后更改下拉值时,它将显示。为什么 <!DOCTYPE html> <html> <head> <link data-require="bootstrap-css@3.x" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapc
<!DOCTYPE html>
<html>
<head>
<link data-require="bootstrap-css@3.x" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" />
<link rel="stylesheet" href="style.css" />
</head>
<body ng-app="test" ng-controller="FormController">
<form name="ngform" sf-schema="schema" sf-form="form" sf-model="model" sf-options="{ formDefaults: { ngModelOptions: { updateOn: 'blur' } }}" ng-submit="onSubmit(ngform)"></form>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="//dl.dropboxusercontent.com/s/icrciconaesuw29/tv4.js?m="></script>
<script data-require="angular.js@*" data-semver="1.3.0-beta.18" src="//code.angularjs.org/1.3.0-beta.18/angular.js"></script>
<script src="//dl.dropboxusercontent.com/s/unk0id7tmc9w0mm/angular-sanitize.js?m="></script>
<script src="//dl.dropboxusercontent.com/s/rk0dfetihiqs7bi/ObjectPath.js"></script>
<script src="//dl.dropboxusercontent.com/s/8fq4c4t7jct4w4h/schema-form.js?m="></script>
<script type="text/javascript" src="//textalk.github.io/angular-schema-form/dist/bootstrap-decorator.min.js"></script>
<script>
angular.module('test', ['schemaForm']).controller('FormController', function($scope, $http) {
$scope.schema = {
type: "object",
properties: {
name: {
type: "string",
minLength: 2,
title: "Name",
description: "Name or alias",
required: true
},
"student": {
type: "string",
title: "studentname",
description: "Name or student",
required: false
},
"email": {
"title": "Email",
"type": "string",
"minLength": 2,
"pattern": "^\\S+@\\S+$",
onChange: function(modelValue,form) {
console.log("Password is"+modelValue);
},
validationMessage: {
200: "Address is too short, man.",
"default": "Just write a proper address, will you?" //Special catch all error message
},
"description": "Email will be used for evil.",
required: true
},
title: {
type: "string",
required: true,
enum: ['dr', 'jr', 'sir', 'mrs', 'mr', 'NaN', 'dj']
}
}
};
$scope.form = [
"*", {
type: "submit",
title: "Save"
}
];
$scope.model = {};
$scope.onSubmit = function(form) {
// First we broadcast an event so all fields validate themselves
$scope.$broadcast('schemaFormValidate');
// Then we check if the form is valid
if (form.$valid) {
// ... do whatever you need to do with your data.
}
}
})
</script>
</body>
</html>
angular.module('test',['schemaForm']).controller('FormController',function($scope,$http){
$scope.schema={
类型:“对象”,
特性:{
姓名:{
键入:“字符串”,
最小长度:2,
标题:“姓名”,
描述:“姓名或别名”,
必填项:true
},
“学生”:{
键入:“字符串”,
标题:“学生姓名”,
描述:“姓名或学生”,
必填项:false
},
“电子邮件”:{
“标题”:“电子邮件”,
“类型”:“字符串”,
“最小长度”:2,
“模式”:“^\\S+@\\S+$”,
onChange:函数(modelValue、form){
console.log(“密码为”+modelValue);
},
验证消息:{
200:“地址太短了,伙计。”,
“默认值”:“请写一个正确的地址,好吗?”//特殊捕获所有错误消息
},
“说明”:“电子邮件将用于邪恶。”,
必填项:true
},
标题:{
键入:“字符串”,
要求:正确,
枚举:['dr','jr','sir','mrs','mr','NaN','dj']
}
}
};
$scope.form=[
"*", {
键入:“提交”,
标题:“保存”
}
];
$scope.model={};
$scope.onSubmit=函数(表单){
//首先,我们广播一个事件,以便所有字段都进行自我验证
$scope.$broadcast('schemaFormValidate');
//然后我们检查表格是否有效
如果(表格$valid){
//…对您的数据执行任何需要执行的操作。
}
}
})
我正在使用此文档:已编辑
ngModelOptions
适用于表单,而不是架构。您必须覆盖表单定义中的选项,而不是将其保留为全局设置:
$scope.form = [
"name",
"student",
"email",
{
key: "title",
ngModelOptions: { updateOn: 'default' }
},
{
type: "submit",
title: "Save"
}
];