0

私はこのコードを持っていますhttp://plnkr.co/edit/kiH0Ge?p=preview

<!doctype html>
<html ng-app="plunker" >
<head>
  <meta charset="utf-8">
  <title>AngularJS Plunker</title>
  <link rel="stylesheet" href="style.css">
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.1/angular.js"></script>
  <script src="app.js"></script>
</head>
<body ng-controller="MainCtrl">
  <choice-tree ng-model="myTree" children="true"></choice-tree>
  <hr />
  $scope.myTree = {{myTree | json}}
</body>
</html>

パラメータcheckChildrenを追加しました

<choice-tree ng-model="myTree" checkChildren="true"></choice-tree>

次に、checkディレクティブで関数を条件付きで実行したい

if(scope.checkChildren === 'true') 
   checkChildren(choice);

しかし、それは機能しません。

孤立したスコープがあることは知っていますが、ツリーを構築する方法。

4

2 に答える 2

0

私の理解が正しければ、それは単純なタイプミスだと思います。少し変更を加えるだけで、機能しているようです:http: //plnkr.co/edit/BJqsl3

あなたはブール値をチェックしたい、例えばscope.checkChildren === true に対してではない'true'

【編集】スペックがよくわからなかったようです

if上で指摘し たステートメントを削除して呼び出すとcheckChildren()、機能します。これはあなたが意図していることですか?それに応じてプランクが更新されます。

于 2012-09-20T09:02:17.960 に答える
0

これですべてが機能しますhttp://plnkr.co/edit/5lLGIQ?p=preview

私は子供を子供と一緒に変えましたそしてこれ(重要)

$compile('<choice-tree ng-model="choice.children" children="{{children}}"></choice-tree>')(scope);

$compile('<choice-tree ng-model="choice.children" withchildren="'+scope.withchildren+'"></choice-tree>')(scope);

http://plnkr.co/edit/5lLGIQ?p=preview

于 2012-09-20T09:57:13.917 に答える