how to correctly assign a controller to a directive so 2 directives can communicate to each other. When I set the require argument of the second directive to the name of the first directive i get an error in the console:
Error: No controller: dir at Error () at getControllers (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js:4132:19) at nodeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js:4259:35) at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js:3869:15) at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js:3872:13) at nodeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js:4252:24) at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js:3869:15) at compositeLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js:3872:13) at publicLinkFn (http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js:3775:30) at http://ajax.googleapis.com/ajax/libs/angularjs/1.0.4/angular.js:934:25
<div class="btn btn-danger" dir2="">
angular.js:5601(anonymous function)angular.js:5601
(anonymous function)angular.js:4698
nodeLinkFnangular.js:4261
compositeLinkFnangular.js:3869
compositeLinkFnangular.js:3872
nodeLinkFnangular.js:4252
compositeLinkFnangular.js:3869
compositeLinkFnangular.js:3872
publicLinkFnangular.js:3775
(anonymous function)angular.js:934
Scope.$evalangular.js:7905
Scope.$applyangular.js:7985
(anonymous function)angular.js:932
invokeangular.js:2813
bootstrapangular.js:930
angularInitangular.js:906
(anonymous function)angular.js:14600
cjquery-latest.min.js:3
p.fireWithjquery-latest.min.js:3
b.extend.readyjquery-latest.min.js:3
H
Here's an example in plnkr.
Edit :
I'm trying to do something that is present in a lot of websites, change the view template by clicking on a button or link from list view to thumbnails view etc... I thought about making 2 directives one called "switcher" for the button switcher and the other called "switchable-view" for the view. here's a plnkr with an example code. The idea is when i click on the "switcher" directive it switch the template in the switchable directive which will result on switching the view, I hope this is clear enough. what i'm trying to do is something like this plnkr
Thanks in advance.