2

これがコードです、理想的には私が見るべきです

親: 真

トグルをクリックすると

ただし、機能しません

プランカーはこちら

<body ng-controller="MainCtrl">
  <button type="button" ng-click='isParentShown= !isParentShown' >Toggle</button>
  <div><span>Controller-isParentShown: {{isParentShown}}</span></div>
  <parent isShown='isParentShown'></parent>

</body>


var app = angular.module('plunker', []).directive('parent',function(){
    return {
        restrict: 'E',
        replace: true,
        scope: {
                isShown: '='
        },
        template: '<span>Parent: {{isShown}}</span>'
    };
}).directive('child',function(){
    return {
        restrict: 'E',
        replace: true,
        template:'<span>Child: {{isChildShown}}</span>',
        scope: {
                isChildShown: '@'
        }
    };
});
app.controller('MainCtrl', function($scope) {
  $scope.isParentShown = false;
});
4

1 に答える 1

3

問題は属性の大文字と小文字です。isShown バインディングを定義すると、is-shownoris:shown属性が必要になります。これが固定プランカーです: http://plnkr.co/edit/UOigth

于 2012-10-26T20:55:57.153 に答える