在指令之间进行通信

时间:2015-08-04 14:19:56

标签: angularjs angularjs-directive

我试图让两个指令互相交谈。我正在尝试关注http://jsfiddle.net/api/post/library/pure/。这是我的代码:

Directives = angular.module("app.directives", []);
Directives.directive('basket', function () {
return {
    restrict: "E",
    controller: function($scope, $element, $attrs) {
        $scope.content = [];
    },
    link: function(scope, element) {
    }
};

});

Directives.directive('appple', function ($compile) {
return {
    require: "basket",
    link: function (scope, elem, attrs, ngModel, basketCtrl) {

...

我的错误是: 错误:$ compile:ctreq 缺少必需的控制器 无法找到指令'apple'所需的控制器'篮子'!

有什么想法吗?

由于

这是我的标记

<basket apple></basket>
<div easyui-layout fit="true" style="height:100%;">
<div data-options="region:'west',title:'Asset Tree',split:true" style="width:30%;">
    <table assets-treegrid ng-model="assets" fit="true" loadMsg=""
           singleselect="true" idField="id" treeField="name"></table>
</div>
<div region="center">
    <div easyui-layout fit="true">
        <div data-options="region:'north',split:true" style="height:40%;">
            <table id="tg" alarms-treegrid ng-model="alarms" pagination="false" fit="true"
                   rownumbers="true" fitColumns="true" singleSelect="true" idField="id"></table>
        </div>
        <div data-options="region:'center'">      
        </div>
    </div>
</div>

Directives.directive('alarmsTreegrid', function ($compile) {
return {
    //restrict: 'AE',
    require: "basket",
    //require: "easyuiWindow",
    link: function (scope, elem, attrs, ngModel, basketCtrl) {

0 个答案:

没有答案