Closed beatelite closed 8 years ago
Just figured it out. I was using controllerAs and binding the data to the controller vs the $scope. I was calling the {{DemoCtrl.title}} correctly but didn't realize I need to call the can('manage_content') from the controller as well.
final code block that did it:
<a ng-href="edit/{{ DemoCtrl.id }}" ng-show="DemoCtrl.can('manage_content')">Edit</a>
I'm newish to angular but I swear I'm hooking it up right.
I have the script set in the head and the
['mm.acl']
declared in on my app.my app.js file:
I have the following example in in my main.js file:
I have the example in my controller.js
app.controller('DemoCtrl', ['$scope', 'AclService', function ($scope, AclService) { $scope.can = AclService.can; $scope.id = 22; $scope.title = 'My Demo Title'; }]);
and the markup in my view.html (and yes the controller.js is loading on this page)
<h1>{{ title }}</h1>
<a ng-href="edit/{{ id }}" ng-show="can('manage_content')">Edit</a>
When
console.log(AclService.can());
- I get false.When I
console.log(AclService.hasRole());
- I get falseWhen I
console.log(aclData);
- I see the object.The role is set to admin so I expect that I'll see the edit button but I don't. Why? What am I missing?