I have some issues with angular. I have a directive with link function like this:
link : function(scope, element, attrs, ctrl) {
element.bind("click", function(e) {
$rootScope.$emit('FIELD-TYPE', {
field_type : scope.field.field_type.valueOf()
});
});
}
and another directive on a sibling scope
$rootScope.$on('FIELD-TYPE', function(event, args) {
scope.field_type = args.field_type;
element.children().remove();
var template = $templateCache.get('propertyBox');
element.append(template);
$compile(element.contents())(scope);
});
so far the $emit gets captured and the content gets loaded. But in the content I have some bindings via ng-model. The values aren't sent over between the directives, they have other scopes, so ma question is.. How to setup the to way data binding between those scopes? or is my approach bad?
greets