2015-10-14 93 views
0

我使用的角度,引导日历资料库,文档可以让我加我的自定义模板,只是增加使用装饰正确的方法angularjs

app.config(function($provide) { 
    $provide.decorator('mwlCalendarDayDirective', function($delegate) { 
    var directive = $delegate[0]; 
    delete directive.template; //the calendar uses template instead of template-url so you need to delete this 
    directive.templateUrl = 'path/to/my/slide/box/template.html'; 
    return $delegate; 
    }); 
}); 

这是我很好,但我的问题是,以取代与另一个模板,它保留了相同的控制器?

回答

1

是的,装饰这样的指令是完全正确的,它们只是包含(按其注册顺序)的Directive后缀的服务。这种方法修改了指定的属性,同时保持DDO的其余部分不变。

对于其他DDO属性,除compile /(post)link/pre(链接)之外,该过程是直接的,这对于修补有点棘手。