码迷,mamicode.com
首页 > 其他好文 > 详细

angular指令

时间:2015-06-23 00:51:58      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

require

引用其他controller

var app = angular.modeule(‘myapp‘,[]);

app.directive(‘common‘,function(){
    return {
    ...
    controller: function($scope){
        this.method1 = function(){
        };
        this.method2 = function(){
        };
    },
    ...
    }
});

app.directive(‘d1‘,function(){
    return {
    ...
    require: ‘?^common‘,
    link: function(scope,elem,attrs,common){
        scope.method1 = common.method1;
        ..
        },
    ...
    }
});

app.directive(‘d2‘,function(){
    return {
    ...
    require: ‘?^common‘,
    link: function(scope,elem,attrs,common){
        scope.method1 = common.method1;
        ..
        },
    ...
    }
});

 

angular指令

标签:

原文地址:http://www.cnblogs.com/yfann/p/4594307.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!