Skip to content

Instantly share code, notes, and snippets.

@mattiaaccornero
Last active August 29, 2015 14:24
Show Gist options
  • Save mattiaaccornero/f9e835c1b4c20b8994db to your computer and use it in GitHub Desktop.
Save mattiaaccornero/f9e835c1b4c20b8994db to your computer and use it in GitHub Desktop.
ngHide on custom directive
...
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'
},...]
]
},...
}
...
});
...
<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