1

次のカスタム要素に ngshow を動的に追加したいのですが...どうすればいいですか?

<toggler on-enable="main.enable()" on-disable="main.disable()">
  <div style="width:100px;height:100px;background-color:#2fa">
    <on>On state</on>
    <off>Off state</off>
  </div>
</toggler>

cf.directive('toggler', function () {
    return {
        restrict: 'AE',
        scope: {
            state: true,
            onEnable: '&',
            onDisable: '&'
        },
        compile: function (elem, attrs) {
            var onElem = elem.find('on');
            var offElem = elem.find('off');
            // WANT TO DO THIS
            // onElem.ngShow = 'state';
            // offElem.ngShow = '!state';
        }
    };
});
4

1 に答える 1