I have shop
attribute, which I want to treat differently, depending on what type passed into (it can be string or object). How do I properly bind this attribute, so that I could pass string and object, and then treat it differently, depending on the passed type?
This way object passing works perfectly fine, but passing a string gives this attribute a value '0':
angular.module('showcaseApp')
.directive('card', function ($window, $state) {
return {
templateUrl: '/card.html',
restrict: 'E',
replace: true,
scope: {
shop: '='
},
link: function(scope, element, attrs) {
attrs.$observe('shop', function (value) {
if (value) {
}
});
}
};
});
Binding with &
allows me to pass a string (catch it with $observe), but an object can't be passed this way. And I want to be able to pass both. This can be solved only by creating a new attribute with different binding?