首页 > 其他 > 详细

angular指令

时间:2015-06-23 00:49:55      阅读:163      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!