Last active
August 29, 2015 14:24
-
-
Save mattiaaccornero/f9e835c1b4c20b8994db to your computer and use it in GitHub Desktop.
ngHide on custom directive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
angular.module('myApp').directive('action', function(){ | |
return { | |
restrict: 'E', | |
scope: { | |
action: '=ngModel' | |
}, | |
template: '<button ng-click="$parent.actionClicked(action, this)" data-type="action">{{action.name}} ({{action.isHidden}})</button>', | |
replace: true | |
} | |
}); | |
... | |
angular.module('myApp').controller('ToolCtrl', ... | |
... | |
$scope.action_buttons = { | |
'oneClickBtns': { | |
'class': 'btn-success', | |
'buttons':[ | |
[{ | |
'name':'Button One', | |
'type': 'btnOne', | |
'isHidden': false | |
},...], | |
[{ | |
'name': 'Button Two', | |
'type': 'btnTwo', | |
'isHidden': true, | |
'class': 'btn-yellow' | |
},...] | |
] | |
},... | |
} | |
... | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<div class="row" ng-repeat="btnGroup in action_buttons.oneClickBtns.buttons"> | |
<action ng-repeat="elem in btnGroup" ng-model="elem" class="btn btn-xs {{elem.class ? elem.class : action_buttons.oneClickBtns.class}} {{(elem.type==current_action.action_key)?'active':''}}" ng-hide="elem.isHidden"></action> | |
</div> | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment