<div ng-app="app"> <div ng-controller="MyCtl"> <button Superman strength> button 1111</button> <button Superman strength speed> button 22 222</button> </div></div><script>varApp = Angular.module ("app", []); App.controller ("MyCtl", Function ($scope) {$scope. Info=""; $scope. Showinfo=function () {$scope. Info="loading ....."; }; }); App.directive ("Superman", function () {return{scope: {}, Controller:function ($scope) {$scope. arr= []; This. Addl = function () {$scope. Arr.push ("length") }; This. AddS = function () {$scope. Arr.push (" Speed") }; }, Link:function (scope, element, Attrs) {Element.addclass ("btn btn-success"); Element.on ("Click", function () {alert (Scope.arr); }); } } }); App.directive ("Strength", function () {return{require:'^superman', link:function (scope, element, Attrs, ctl) {ctl.addl (); } } }); App.directive (" Speed", function () {return{require:'^superman', link:function (scope, element, Attrs, ctl) {Ctl.adds (); } } });</script>
Angularjs calls between instructions