Ben Aston Ben Aston - 1 year ago 51
AngularJS Question

Is there a way to determine whether a directive scope "&" item has been set to something?

In the following note that

does not have a value.


bar="" /></my-directive>


return function() {
return {
restrict: 'E',
scope: {
foo: '&',
bar: '&',
template: template,
controllerAs: 'ctrl',
controller: controller,

How can I tell in the controller that
has not been set to anything?

I am using Angular 1.4.

Answer Source

Attribute value itself can be checked with

$ == true;

As it was mentioned, & bindings result in wrapper function that is always truthy.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download