我正在使用 Angular Schema Form 生成带有 JSON Schema 的表单我想在用户输入字符串 abc 时显示电子邮件文本字段,但是在输入 abc 后电子邮件文本字段永远不会出现。我认为问题出在变量名的范围或条件中:“name=='abc'” 你能帮帮我吗?有代码
HTML
<html ng-app="myApp">
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="bower_components/angular/angular.js" type="text/javascript"></script>
<script src="bower_components/angular-sanitize/angular-sanitize.js" type="text/javascript"></script>
<script src="bower_components/tv4/tv4.js" type="text/javascript"></script>
<script src="bower_components/objectpath/lib/ObjectPath.js" type="text/javascript"></script>
<script src="bower_components/angular-schema-form/dist/schema-form.js" type="text/javascript"></script>
<script src="bower_components/angular-schema-form/dist/bootstrap-decorator.js" type="text/javascript"></script>
<script src="js/app.js" type="text/javascript"></script>
</head>
<body ng-controller="myCtrl">
<form sf-schema="schema" sf-form="form" sf-model="model"></form>
</body>
</html>
应用程序.js
var myApp = angular.module("myApp", ['schemaForm']);
myApp.controller("myCtrl", function ($scope) {
$scope.schema = {
"type": "object",
"title": "Comment",
"properties": {
"name": {
"title": "Name",
"type": "string"
},
"email": {
"title": "Email",
"type": "string"
}
}
};
$scope.form = [
"name",
{key: "email",
condition: "name=='abc'"
},
{
"type": "submit",
"style": "btn-info",
"title": "OK"
}
];
$scope.model = {};
});