2016-04-20 21 views
1

角型スキーマフォームを使用してJSONスキーマを使用してフォームを生成します ユーザーが文字列abcを入力したときにメールテキストフィールドを表示しますが、abcを入力した後はメールテキストフィールドは表示されません。私は問題が変数名またはの条件のスコープにあると思う: "name == 'abc'" 私に手を差し伸べてもいいですか?角度スキーマフォーム条件

<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あなたは条件がスコープに何と連携としてあなたは、直接名前を使用できないことを見ることができますdocs

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 = {}; 
}); 

答えて

1

、ないコード

HTMLがありますちょうどモデル。だから "name"を "model.name == 'abc'"に置き換えると動作します。私のexample hereを参照してください。

関連する問題