This guy is in this directive: Dynamic template in attribute-based directive?
Anyway, this is what I'm trying to accomplish.
This <titlebar> directive can accept the edit-button attribute. If this exists, and when the button is clicked, I would like to set the $ scope variable in my controllers, which will switch the button visibility for deleting / editing the element.
For example, if I set $scope.currentlyEditting = true; in my directive, I bind this to the controller and then use ng-show to show / hide the controls. I just don't know how to get this data in my controller.
titleBar directive :
robus.directive("titlebar", function() { return { restrict: "E", template: "<header class='bar-title' ng-class='{\"sub-view\": view}'>"+ "<a class='button' ng-click='goBack()' ng-show='back'><i class='icon-arrow-left'></i> Back</a>" + "<h1 class='title' ng-transclude>" + "<span class='sub-title' ng-show='view'>{{view}}</span></h1>" + "<a class='button' ng-click='showEdit()' ng-show='edit'>Edit</a>" + "</header>", scope: { view: '@view', edit: '@editButton', back: '@backButton' }, transclude: true, replace: true, link: function ($scope, $element, attrs, ctrl) { // $scope.$apply(); }, controller: function($scope, $element, $attrs, $location, $routeParams) { /* simple back button implementation */ $scope.goBack = function() { history.back(-1) } // $scope.showEdit = function() { // $scope.currentlyEditting = true; // } } } });
source share