I'm using Angular Schema Form to generate a form with JSON Schema I want to show the email textfield when the user enters the string abc, however the email textfield never appear after entering abc. I think that the problem is in the scope of the variable name or in condition: "name=='abc'" May you give me a hand? there is the code
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>
app.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 = {};
});
In the docs you can see that you can't use name directly, as condition works with anything on scope, not just the model. So replacing "name" with "model.name=='abc'" for example will work. See my example here.